/**
  * Writes a SyncContact to MAPI
  *
  * @param mixed             $mapimessage
  * @param SyncContact       $contact
  *
  * @access private
  * @return boolean
  */
 private function setContact($mapimessage, $contact)
 {
     mapi_setprops($mapimessage, array(PR_MESSAGE_CLASS => "IPM.Contact"));
     // normalize email addresses
     if (isset($contact->email1address) && ($contact->email1address = $this->extractEmailAddress($contact->email1address)) === false) {
         unset($contact->email1address);
     }
     if (isset($contact->email2address) && ($contact->email2address = $this->extractEmailAddress($contact->email2address)) === false) {
         unset($contact->email2address);
     }
     if (isset($contact->email3address) && ($contact->email3address = $this->extractEmailAddress($contact->email3address)) === false) {
         unset($contact->email3address);
     }
     $contactmapping = MAPIMapping::GetContactMapping();
     $contactprops = MAPIMapping::GetContactProperties();
     $this->setPropsInMAPI($mapimessage, $contact, $contactmapping);
     ///set display name from contact's properties
     $cname = $this->composeDisplayName($contact);
     //get contact specific mapi properties and merge them with the AS properties
     $contactprops = array_merge($this->getPropIdsFromStrings($contactmapping), $this->getPropIdsFromStrings($contactprops));
     //contact specific properties to be set
     $props = array();
     //need to be set in order to show contacts properly in outlook and wa
     $nremails = array();
     $abprovidertype = 0;
     if (isset($contact->email1address)) {
         $this->setEmailAddress($contact->email1address, $cname, 1, $props, $contactprops, $nremails, $abprovidertype);
     }
     if (isset($contact->email2address)) {
         $this->setEmailAddress($contact->email2address, $cname, 2, $props, $contactprops, $nremails, $abprovidertype);
     }
     if (isset($contact->email3address)) {
         $this->setEmailAddress($contact->email3address, $cname, 3, $props, $contactprops, $nremails, $abprovidertype);
     }
     $props[$contactprops["addressbooklong"]] = $abprovidertype;
     $props[$contactprops["displayname"]] = $props[$contactprops["subject"]] = $cname;
     //pda multiple e-mail addresses bug fix for the contact
     if (!empty($nremails)) {
         $props[$contactprops["addressbookmv"]] = $nremails;
     }
     //set addresses
     $this->setAddress("home", $contact->homecity, $contact->homecountry, $contact->homepostalcode, $contact->homestate, $contact->homestreet, $props, $contactprops);
     $this->setAddress("business", $contact->businesscity, $contact->businesscountry, $contact->businesspostalcode, $contact->businessstate, $contact->businessstreet, $props, $contactprops);
     $this->setAddress("other", $contact->othercity, $contact->othercountry, $contact->otherpostalcode, $contact->otherstate, $contact->otherstreet, $props, $contactprops);
     //set the mailing address and its type
     if (isset($props[$contactprops["businessaddress"]])) {
         $props[$contactprops["mailingaddress"]] = 2;
         $this->setMailingAddress($contact->businesscity, $contact->businesscountry, $contact->businesspostalcode, $contact->businessstate, $contact->businessstreet, $props[$contactprops["businessaddress"]], $props, $contactprops);
     } elseif (isset($props[$contactprops["homeaddress"]])) {
         $props[$contactprops["mailingaddress"]] = 1;
         $this->setMailingAddress($contact->homecity, $contact->homecountry, $contact->homepostalcode, $contact->homestate, $contact->homestreet, $props[$contactprops["homeaddress"]], $props, $contactprops);
     } elseif (isset($props[$contactprops["otheraddress"]])) {
         $props[$contactprops["mailingaddress"]] = 3;
         $this->setMailingAddress($contact->othercity, $contact->othercountry, $contact->otherpostalcode, $contact->otherstate, $contact->otherstreet, $props[$contactprops["otheraddress"]], $props, $contactprops);
     }
     if (isset($contact->picture)) {
         $picbinary = base64_decode($contact->picture);
         $picsize = strlen($picbinary);
         if ($picsize < MAX_EMBEDDED_SIZE) {
             $props[$contactprops["haspic"]] = false;
             // TODO contact picture handling
             // check if contact has already got a picture. delete it first in that case
             // delete it also if it was removed on a mobile
             $picprops = mapi_getprops($mapimessage, array($props[$contactprops["haspic"]]));
             if (isset($picprops[$props[$contactprops["haspic"]]]) && $picprops[$props[$contactprops["haspic"]]]) {
                 ZLog::Write(LOGLEVEL_DEBUG, "Contact already has a picture. Delete it");
                 $attachtable = mapi_message_getattachmenttable($mapimessage);
                 mapi_table_restrict($attachtable, MAPIUtils::GetContactPicRestriction());
                 $rows = mapi_table_queryallrows($attachtable, array(PR_ATTACH_NUM));
                 if (isset($rows) && is_array($rows)) {
                     foreach ($rows as $row) {
                         mapi_message_deleteattach($mapimessage, $row[PR_ATTACH_NUM]);
                     }
                 }
             }
             // only set picture if there's data in the request
             if ($picbinary !== false && $picsize > 0) {
                 $props[$contactprops["haspic"]] = true;
                 $pic = mapi_message_createattach($mapimessage);
                 // Set properties of the attachment
                 $picprops = array(PR_ATTACH_LONG_FILENAME_A => "ContactPicture.jpg", PR_DISPLAY_NAME => "ContactPicture.jpg", 0x7fff000b => true, PR_ATTACHMENT_HIDDEN => false, PR_ATTACHMENT_FLAGS => 1, PR_ATTACH_METHOD => ATTACH_BY_VALUE, PR_ATTACH_EXTENSION_A => ".jpg", PR_ATTACH_NUM => 1, PR_ATTACH_SIZE => $picsize, PR_ATTACH_DATA_BIN => $picbinary);
                 mapi_setprops($pic, $picprops);
                 mapi_savechanges($pic);
             }
         }
     }
     if (isset($contact->asbody)) {
         $this->setASbody($contact->asbody, $props, $contactprops);
     }
     //set fileas
     if (defined('FILEAS_ORDER')) {
         $lastname = isset($contact->lastname) ? $contact->lastname : "";
         $firstname = isset($contact->firstname) ? $contact->firstname : "";
         $middlename = isset($contact->middlename) ? $contact->middlename : "";
         $company = isset($contact->companyname) ? $contact->companyname : "";
         $props[$contactprops["fileas"]] = Utils::BuildFileAs($lastname, $firstname, $middlename, $company);
     } else {
         ZLog::Write(LOGLEVEL_DEBUG, "FILEAS_ORDER not defined");
     }
     mapi_setprops($mapimessage, $props);
 }
 /**
  * Function which replaces attachments with copy_from in copy_to.
  *@param resource $copy_from MAPI_message from which attachments are to be copied.
  *@param resource $copy_to MAPI_message to which attachment are to be copied.
  *@param boolean $copyExceptions if true then all exceptions should also be sent as attachments
  */
 function replaceAttachments($copy_from, $copy_to, $copyExceptions = true)
 {
     /* remove all old attachments */
     $attachmentTable = mapi_message_getattachmenttable($copy_to);
     if ($attachmentTable) {
         $attachments = mapi_table_queryallrows($attachmentTable, array(PR_ATTACH_NUM, PR_ATTACH_METHOD, PR_EXCEPTION_STARTTIME));
         foreach ($attachments as $attach_props) {
             /* remove exceptions too? */
             if (!$copyExceptions && $attach_props[PR_ATTACH_METHOD] == 5 && isset($attach_props[PR_EXCEPTION_STARTTIME])) {
                 continue;
             }
             mapi_message_deleteattach($copy_to, $attach_props[PR_ATTACH_NUM]);
         }
     }
     $attachmentTable = false;
     /* copy new attachments */
     $attachmentTable = mapi_message_getattachmenttable($copy_from);
     if ($attachmentTable) {
         $attachments = mapi_table_queryallrows($attachmentTable, array(PR_ATTACH_NUM, PR_ATTACH_METHOD, PR_EXCEPTION_STARTTIME));
         foreach ($attachments as $attach_props) {
             if (!$copyExceptions && $attach_props[PR_ATTACH_METHOD] == 5 && isset($attach_props[PR_EXCEPTION_STARTTIME])) {
                 continue;
             }
             $attach_old = mapi_message_openattach($copy_from, (int) $attach_props[PR_ATTACH_NUM]);
             $attach_newResourceMsg = mapi_message_createattach($copy_to);
             mapi_copyto($attach_old, array(), array(), $attach_newResourceMsg, 0);
             mapi_savechanges($attach_newResourceMsg);
         }
     }
 }
Example #3
0
 /**
  * Function which deletes all attachments of a message.
  */
 function deleteAttachments()
 {
     $attachments = mapi_message_getattachmenttable($this->message);
     $attachTable = mapi_table_queryallrows($attachments, array(PR_ATTACH_NUM, PR_ATTACHMENT_HIDDEN));
     foreach ($attachTable as $attachRow) {
         if (isset($attachRow[PR_ATTACHMENT_HIDDEN]) && $attachRow[PR_ATTACHMENT_HIDDEN]) {
             mapi_message_deleteattach($this->message, $attachRow[PR_ATTACH_NUM]);
         }
     }
 }
Example #4
0
 function _setContact($mapimessage, $contact)
 {
     mapi_setprops($mapimessage, array(PR_MESSAGE_CLASS => "IPM.Contact"));
     // normalize email addresses
     if (isset($contact->email1address) && ($contact->email1address = $this->_extractEmailAddress($contact->email1address)) === false) {
         unset($contact->email1address);
     }
     if (isset($contact->email2address) && ($contact->email2address = $this->_extractEmailAddress($contact->email2address)) === false) {
         unset($contact->email2address);
     }
     if (isset($contact->email3address) && ($contact->email3address = $this->_extractEmailAddress($contact->email3address)) === false) {
         unset($contact->email3address);
     }
     $this->_setPropsInMAPI($mapimessage, $contact, $this->_contactmapping);
     // Set display name and subject to a combined value of firstname and lastname
     $cname = isset($contact->prefix) ? u2w($contact->prefix) . " " : "";
     $cname .= u2w($contact->firstname);
     $cname .= isset($contact->middlename) ? " " . u2w($contact->middlename) : "";
     $cname .= " " . u2w($contact->lastname);
     $cname .= isset($contact->suffix) ? " " . u2w($contact->suffix) : "";
     $cname = trim($cname);
     //set contact specific mapi properties
     $props = array();
     $nremails = array();
     $abprovidertype = 0;
     if (isset($contact->email1address)) {
         $nremails[] = 0;
         $abprovidertype |= 1;
         $props[$this->_getPropIDFromString("PT_BINARY:{00062004-0000-0000-C000-000000000046}:0x8085")] = mapi_createoneoff($cname, "SMTP", $contact->email1address);
         //emailentryid
         $props[$this->_getPropIDFromString("PT_STRING8:{00062004-0000-0000-C000-000000000046}:0x8080")] = "{$cname} ({$contact->email1address})";
         //displayname
         $props[$this->_getPropIDFromString("PT_STRING8:{00062004-0000-0000-C000-000000000046}:0x8082")] = "SMTP";
         //emailadresstype
         $props[$this->_getPropIDFromString("PT_STRING8:{00062004-0000-0000-C000-000000000046}:0x8084")] = $contact->email1address;
         //original emailaddress
     }
     if (isset($contact->email2address)) {
         $nremails[] = 1;
         $abprovidertype |= 2;
         $props[$this->_getPropIDFromString("PT_BINARY:{00062004-0000-0000-C000-000000000046}:0x8095")] = mapi_createoneoff($cname, "SMTP", $contact->email2address);
         //emailentryid
         $props[$this->_getPropIDFromString("PT_STRING8:{00062004-0000-0000-C000-000000000046}:0x8090")] = "{$cname} ({$contact->email2address})";
         //displayname
         $props[$this->_getPropIDFromString("PT_STRING8:{00062004-0000-0000-C000-000000000046}:0x8092")] = "SMTP";
         //emailadresstype
         $props[$this->_getPropIDFromString("PT_STRING8:{00062004-0000-0000-C000-000000000046}:0x8094")] = $contact->email2address;
         //original emailaddress
     }
     if (isset($contact->email3address)) {
         $nremails[] = 2;
         $abprovidertype |= 4;
         $props[$this->_getPropIDFromString("PT_BINARY:{00062004-0000-0000-C000-000000000046}:0x80A5")] = mapi_createoneoff($cname, "SMTP", $contact->email3address);
         //emailentryid
         $props[$this->_getPropIDFromString("PT_STRING8:{00062004-0000-0000-C000-000000000046}:0x80A0")] = "{$cname} ({$contact->email3address})";
         //displayname
         $props[$this->_getPropIDFromString("PT_STRING8:{00062004-0000-0000-C000-000000000046}:0x80A2")] = "SMTP";
         //emailadresstype
         $props[$this->_getPropIDFromString("PT_STRING8:{00062004-0000-0000-C000-000000000046}:0x80A4")] = $contact->email3address;
         //original emailaddress
     }
     $props[$this->_getPropIDFromString("PT_LONG:{00062004-0000-0000-C000-000000000046}:0x8029")] = $abprovidertype;
     $props[PR_DISPLAY_NAME] = $cname;
     $props[PR_SUBJECT] = $cname;
     //pda multiple e-mail addresses bug fix for the contact
     if (!empty($nremails)) {
         $props[$this->_getPropIDFromString("PT_MV_LONG:{00062004-0000-0000-C000-000000000046}:0x8028")] = $nremails;
     }
     //addresses' fix
     $homecity = $homecountry = $homepostalcode = $homestate = $homestreet = $homeaddress = "";
     if (isset($contact->homecity)) {
         $props[PR_HOME_ADDRESS_CITY] = $homecity = u2w($contact->homecity);
     }
     if (isset($contact->homecountry)) {
         $props[PR_HOME_ADDRESS_COUNTRY] = $homecountry = u2w($contact->homecountry);
     }
     if (isset($contact->homepostalcode)) {
         $props[PR_HOME_ADDRESS_POSTAL_CODE] = $homepostalcode = u2w($contact->homepostalcode);
     }
     if (isset($contact->homestate)) {
         $props[PR_HOME_ADDRESS_STATE_OR_PROVINCE] = $homestate = u2w($contact->homestate);
     }
     if (isset($contact->homestreet)) {
         $props[PR_HOME_ADDRESS_STREET] = $homestreet = u2w($contact->homestreet);
     }
     $homeaddress = buildAddressString($homestreet, $homepostalcode, $homecity, $homestate, $homecountry);
     if ($homeaddress) {
         $props[$this->_getPropIDFromString("PT_STRING8:{00062004-0000-0000-C000-000000000046}:0x801A")] = $homeaddress;
     }
     $businesscity = $businesscountry = $businesspostalcode = $businessstate = $businessstreet = $businessaddress = "";
     if (isset($contact->businesscity)) {
         $props[$this->_getPropIDFromString("PT_STRING8:{00062004-0000-0000-C000-000000000046}:0x8046")] = $businesscity = u2w($contact->businesscity);
     }
     if (isset($contact->businesscountry)) {
         $props[$this->_getPropIDFromString("PT_STRING8:{00062004-0000-0000-C000-000000000046}:0x8049")] = $businesscountry = u2w($contact->businesscountry);
     }
     if (isset($contact->businesspostalcode)) {
         $props[$this->_getPropIDFromString("PT_STRING8:{00062004-0000-0000-C000-000000000046}:0x8048")] = $businesspostalcode = u2w($contact->businesspostalcode);
     }
     if (isset($contact->businessstate)) {
         $props[$this->_getPropIDFromString("PT_STRING8:{00062004-0000-0000-C000-000000000046}:0x8047")] = $businessstate = u2w($contact->businessstate);
     }
     if (isset($contact->businessstreet)) {
         $props[$this->_getPropIDFromString("PT_STRING8:{00062004-0000-0000-C000-000000000046}:0x8045")] = $businessstreet = u2w($contact->businessstreet);
     }
     $businessaddress = buildAddressString($businessstreet, $businesspostalcode, $businesscity, $businessstate, $businesscountry);
     if ($businessaddress) {
         $props[$this->_getPropIDFromString("PT_STRING8:{00062004-0000-0000-C000-000000000046}:0x801B")] = $businessaddress;
     }
     $othercity = $othercountry = $otherpostalcode = $otherstate = $otherstreet = $otheraddress = "";
     if (isset($contact->othercity)) {
         $props[PR_OTHER_ADDRESS_CITY] = $othercity = u2w($contact->othercity);
     }
     if (isset($contact->othercountry)) {
         $props[PR_OTHER_ADDRESS_COUNTRY] = $othercountry = u2w($contact->othercountry);
     }
     if (isset($contact->otherpostalcode)) {
         $props[PR_OTHER_ADDRESS_POSTAL_CODE] = $otherpostalcode = u2w($contact->otherpostalcode);
     }
     if (isset($contact->otherstate)) {
         $props[PR_OTHER_ADDRESS_STATE_OR_PROVINCE] = $otherstate = u2w($contact->otherstate);
     }
     if (isset($contact->otherstreet)) {
         $props[PR_OTHER_ADDRESS_STREET] = $otherstreet = u2w($contact->otherstreet);
     }
     $otheraddress = buildAddressString($otherstreet, $otherpostalcode, $othercity, $otherstate, $othercountry);
     if ($otheraddress) {
         $props[$this->_getPropIDFromString("PT_STRING8:{00062004-0000-0000-C000-000000000046}:0x801C")] = $otheraddress;
     }
     $mailingadresstype = 0;
     if ($businessaddress) {
         $mailingadresstype = 2;
     } elseif ($homeaddress) {
         $mailingadresstype = 1;
     } elseif ($othercity) {
         $mailingadresstype = 3;
     }
     if ($mailingadresstype) {
         $props[$this->_getPropIDFromString("PT_LONG:{00062004-0000-0000-C000-000000000046}:0x8022")] = $mailingadresstype;
         switch ($mailingadresstype) {
             case 1:
                 $this->_setMailingAdress($homestreet, $homepostalcode, $homecity, $homestate, $homecountry, $homeaddress, $props);
                 break;
             case 2:
                 $this->_setMailingAdress($businessstreet, $businesspostalcode, $businesscity, $businessstate, $businesscountry, $businessaddress, $props);
                 break;
             case 3:
                 $this->_setMailingAdress($otherstreet, $otherpostalcode, $othercity, $otherstate, $othercountry, $otheraddress, $props);
                 break;
         }
     }
     if (isset($contact->picture)) {
         $picbinary = base64_decode($contact->picture);
         $picsize = strlen($picbinary);
         if ($picsize < MAX_EMBEDDED_SIZE) {
             //set the has picture property to true
             $haspic = $this->_getPropIDFromString("PT_BOOLEAN:{00062004-0000-0000-C000-000000000046}:0x8015");
             $props[$haspic] = false;
             //check if contact has already got a picture. delete it first in that case
             //delete it also if it was removed on a mobile
             $picprops = mapi_getprops($mapimessage, array($haspic));
             if (isset($picprops[$haspic]) && $picprops[$haspic]) {
                 debugLog("Contact already has a picture. Delete it");
                 $attachtable = mapi_message_getattachmenttable($mapimessage);
                 mapi_table_restrict($attachtable, getContactPicRestriction());
                 $rows = mapi_table_queryallrows($attachtable, array(PR_ATTACH_NUM));
                 if (isset($rows) && is_array($rows)) {
                     foreach ($rows as $row) {
                         mapi_message_deleteattach($mapimessage, $row[PR_ATTACH_NUM]);
                     }
                 }
             }
             //only set picture if there's data in the request
             if ($picbinary !== false && $picsize > 0) {
                 $props[$haspic] = true;
                 $pic = mapi_message_createattach($mapimessage);
                 // Set properties of the attachment
                 $picprops = array(PR_ATTACH_LONG_FILENAME_A => "ContactPicture.jpg", PR_DISPLAY_NAME => "ContactPicture.jpg", 0x7fff000b => true, PR_ATTACHMENT_HIDDEN => false, PR_ATTACHMENT_FLAGS => 1, PR_ATTACH_METHOD => ATTACH_BY_VALUE, PR_ATTACH_EXTENSION_A => ".jpg", PR_ATTACH_NUM => 1, PR_ATTACH_SIZE => $picsize, PR_ATTACH_DATA_BIN => $picbinary);
                 mapi_setprops($pic, $picprops);
                 mapi_savechanges($pic);
             }
         }
     }
     mapi_setprops($mapimessage, $props);
 }
Example #5
0
 /**
  * Assign a contact picture to a contact
  * @param entryId contact entry id
  * @param contactPicture must be a valid jpeg file. If contactPicture is NULL will remove contact picture from contact if exists
  */
 public function setContactPicture(&$contact, $contactPicture)
 {
     $this->logger->trace("setContactPicture");
     // Find if contact picture is already set
     $contactAttachment = -1;
     $hasattachProp = mapi_getprops($contact, array(PR_HASATTACH));
     if ($hasattachProp) {
         $attachmentTable = mapi_message_getattachmenttable($contact);
         $attachments = mapi_table_queryallrows($attachmentTable, array(PR_ATTACH_NUM, PR_ATTACH_SIZE, PR_ATTACH_LONG_FILENAME, PR_ATTACH_FILENAME, PR_ATTACHMENT_HIDDEN, PR_DISPLAY_NAME, PR_ATTACH_METHOD, PR_ATTACH_CONTENT_ID, PR_ATTACH_MIME_TAG, PR_ATTACHMENT_CONTACTPHOTO, PR_EC_WA_ATTACHMENT_HIDDEN_OVERRIDE));
         foreach ($attachments as $attachmentRow) {
             if (isset($attachmentRow[PR_ATTACHMENT_CONTACTPHOTO]) && $attachmentRow[PR_ATTACHMENT_CONTACTPHOTO]) {
                 $contactAttachment = $attachmentRow[PR_ATTACH_NUM];
                 break;
             }
         }
     }
     // Remove existing attachment if necessary
     if ($contactAttachment != -1) {
         $this->logger->trace("removing existing contact picture");
         $attach = mapi_message_deleteattach($contact, $contactAttachment);
     }
     if ($contactPicture !== NULL) {
         $this->logger->debug("Saving contact picture as attachment");
         // Create attachment
         $attach = mapi_message_createattach($contact);
         // Update contact attachment properties
         $properties = array(PR_ATTACH_SIZE => strlen($contactPicture), PR_ATTACH_LONG_FILENAME => 'ContactPicture.jpg', PR_ATTACHMENT_HIDDEN => false, PR_DISPLAY_NAME => 'ContactPicture.jpg', PR_ATTACH_METHOD => ATTACH_BY_VALUE, PR_ATTACH_MIME_TAG => 'image/jpeg', PR_ATTACHMENT_CONTACTPHOTO => true, PR_ATTACH_DATA_BIN => $contactPicture, PR_ATTACHMENT_FLAGS => 1, PR_ATTACH_EXTENSION_A => '.jpg', PR_ATTACH_NUM => 1);
         mapi_setprops($attach, $properties);
         mapi_savechanges($attach);
     }
     // Test
     if (mapi_last_hresult() > 0) {
         $this->logger->warn("Error saving contact picture: " . get_mapi_error_name());
     } else {
         $this->logger->trace("contact picture done");
     }
 }
Example #6
0
 /**
  * Function will be used to decode smime messages and convert it to normal messages.
  *
  * @param MAPISession       $session
  * @param MAPIStore         $store
  * @param MAPIAdressBook    $addressBook
  * @param MAPIMessage       $message smime message
  *
  * @access public
  * @return void
  */
 public static function ParseSmime($session, $store, $addressBook, &$mapimessage)
 {
     $props = mapi_getprops($mapimessage, array(PR_MESSAGE_CLASS));
     if (isset($props[PR_MESSAGE_CLASS]) && stripos($props[PR_MESSAGE_CLASS], 'IPM.Note.SMIME.MultipartSigned') !== false) {
         // this is a signed message. decode it.
         $attachTable = mapi_message_getattachmenttable($mapimessage);
         $rows = mapi_table_queryallrows($attachTable, array(PR_ATTACH_MIME_TAG, PR_ATTACH_NUM));
         $attnum = false;
         foreach ($rows as $row) {
             if (isset($row[PR_ATTACH_MIME_TAG]) && $row[PR_ATTACH_MIME_TAG] == 'multipart/signed') {
                 $attnum = $row[PR_ATTACH_NUM];
             }
         }
         if ($attnum !== false) {
             $att = mapi_message_openattach($mapimessage, $attnum);
             $data = mapi_openproperty($att, PR_ATTACH_DATA_BIN);
             mapi_message_deleteattach($mapimessage, $attnum);
             mapi_inetmapi_imtomapi($session, $store, $addressBook, $mapimessage, $data, array("parse_smime_signed" => 1));
             ZLog::Write(LOGLEVEL_DEBUG, "Convert a smime signed message to a normal message.");
         }
         mapi_setprops($mapimessage, array(PR_MESSAGE_CLASS => 'IPM.Note.SMIME.MultipartSigned'));
     }
     // TODO check if we need to do this for encrypted (and signed?) message as well
 }