本文整理汇总了PHP中mapi_message_getattachmenttable函数的典型用法代码示例。如果您正苦于以下问题:PHP mapi_message_getattachmenttable函数的具体用法?PHP mapi_message_getattachmenttable怎么用?PHP mapi_message_getattachmenttable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mapi_message_getattachmenttable函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: regenerateTask
/**
* Function which clones current occurrence and sets appropriate properties.
* The original recurring item is moved to next occurrence.
*@param boolean $markComplete true if existing occurrence has to be mark complete else false.
*/
function regenerateTask($markComplete)
{
// Get all properties
$taskItemProps = mapi_getprops($this->message);
if (isset($this->action["subject"])) {
$taskItemProps[$this->proptags["subject"]] = $this->action["subject"];
}
if (isset($this->action["importance"])) {
$taskItemProps[$this->proptags["importance"]] = $this->action["importance"];
}
if (isset($this->action["startdate"])) {
$taskItemProps[$this->proptags["startdate"]] = $this->action["startdate"];
$taskItemProps[$this->proptags["commonstart"]] = $this->action["startdate"];
}
if (isset($this->action["duedate"])) {
$taskItemProps[$this->proptags["duedate"]] = $this->action["duedate"];
$taskItemProps[$this->proptags["commonend"]] = $this->action["duedate"];
}
$folder = mapi_msgstore_openentry($this->store, $taskItemProps[PR_PARENT_ENTRYID]);
$newMessage = mapi_folder_createmessage($folder);
$taskItemProps[$this->proptags["status"]] = $markComplete ? olTaskComplete : olTaskNotStarted;
$taskItemProps[$this->proptags["complete"]] = $markComplete;
$taskItemProps[$this->proptags["percent_complete"]] = $markComplete ? 1 : 0;
// This occurrence has been marked as 'Complete' so disable reminder
if ($markComplete) {
$taskItemProps[$this->proptags["reset_reminder"]] = false;
$taskItemProps[$this->proptags["reminder"]] = false;
$taskItemProps[$this->proptags["datecompleted"]] = $this->action["datecompleted"];
unset($this->action[$this->proptags['datecompleted']]);
}
// Recurrence ends for this item
$taskItemProps[$this->proptags["dead_occurrence"]] = true;
$taskItemProps[$this->proptags["task_f_creator"]] = true;
//OL props
$taskItemProps[$this->proptags["side_effects"]] = 1296;
$taskItemProps[$this->proptags["icon_index"]] = 1280;
// Copy recipients
$recipienttable = mapi_message_getrecipienttable($this->message);
$recipients = mapi_table_queryallrows($recipienttable, array(PR_ENTRYID, PR_DISPLAY_NAME, PR_EMAIL_ADDRESS, PR_RECIPIENT_ENTRYID, PR_RECIPIENT_TYPE, PR_SEND_INTERNET_ENCODING, PR_SEND_RICH_INFO, PR_RECIPIENT_DISPLAY_NAME, PR_ADDRTYPE, PR_DISPLAY_TYPE, PR_RECIPIENT_TRACKSTATUS, PR_RECIPIENT_TRACKSTATUS_TIME, PR_RECIPIENT_FLAGS, PR_ROWID));
$copy_to_recipientTable = mapi_message_getrecipienttable($newMessage);
$copy_to_recipientRows = mapi_table_queryallrows($copy_to_recipientTable, array(PR_ROWID));
foreach ($copy_to_recipientRows as $recipient) {
mapi_message_modifyrecipients($newMessage, MODRECIP_REMOVE, array($recipient));
}
mapi_message_modifyrecipients($newMessage, MODRECIP_ADD, $recipients);
// Copy attachments
$attachmentTable = mapi_message_getattachmenttable($this->message);
if ($attachmentTable) {
$attachments = mapi_table_queryallrows($attachmentTable, array(PR_ATTACH_NUM, PR_ATTACH_SIZE, PR_ATTACH_LONG_FILENAME, PR_ATTACHMENT_HIDDEN, PR_DISPLAY_NAME, PR_ATTACH_METHOD));
foreach ($attachments as $attach_props) {
$attach_old = mapi_message_openattach($this->message, (int) $attach_props[PR_ATTACH_NUM]);
$attach_newResourceMsg = mapi_message_createattach($newMessage);
mapi_copyto($attach_old, array(), array(), $attach_newResourceMsg, 0);
mapi_savechanges($attach_newResourceMsg);
}
}
mapi_setprops($newMessage, $taskItemProps);
mapi_savechanges($newMessage);
// Update body of original message
$msgbody = mapi_message_openproperty($this->message, PR_BODY);
$msgbody = trim($this->windows1252_to_utf8($msgbody), "");
$separator = "------------\r\n";
if (!empty($msgbody) && strrpos($msgbody, $separator) === false) {
$msgbody = $separator . $msgbody;
$stream = mapi_openpropertytostream($this->message, PR_BODY, MAPI_CREATE | MAPI_MODIFY);
mapi_stream_setsize($stream, strlen($msgbody));
mapi_stream_write($stream, $msgbody);
mapi_stream_commit($stream);
}
// We need these properties to notify client
return mapi_getprops($newMessage, array(PR_ENTRYID, PR_PARENT_ENTRYID, PR_STORE_ENTRYID));
}
示例2: replaceAttachments
/**
* 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);
}
}
}
示例3: getExceptionAttachment
/**
* Get an exception attachment based on its basedate
*/
function getExceptionAttachment($base_date)
{
// Retrieve only embedded messages
$attach_res = array(RES_AND, array(array(RES_PROPERTY, array(RELOP => RELOP_EQ, ULPROPTAG => PR_ATTACH_METHOD, VALUE => array(PR_ATTACH_METHOD => 5)))));
$attachments = mapi_message_getattachmenttable($this->message);
$attachRows = mapi_table_queryallrows($attachments, array(PR_ATTACH_NUM), $attach_res);
if (is_array($attachRows)) {
foreach ($attachRows as $attachRow) {
$tempattach = mapi_message_openattach($this->message, $attachRow[PR_ATTACH_NUM]);
$exception = mapi_attach_openobj($tempattach);
$data = mapi_message_getprops($exception, array($this->proptags["basedate"]));
if (isset($data[$this->proptags["basedate"]]) && $this->isSameDay($this->fromGMT($this->tz, $data[$this->proptags["basedate"]]), $base_date)) {
return $tempattach;
}
}
}
return false;
}
示例4: copyAttachments
/**
* Copies attachments from one message to another.
*
* @param MAPIMessage $toMessage
* @param MAPIMessage $fromMessage
*
* @return void
*/
private function copyAttachments(&$toMessage, $fromMessage)
{
$attachtable = mapi_message_getattachmenttable($fromMessage);
$rows = mapi_table_queryallrows($attachtable, array(PR_ATTACH_NUM));
foreach ($rows as $row) {
if (isset($row[PR_ATTACH_NUM])) {
$attach = mapi_message_openattach($fromMessage, $row[PR_ATTACH_NUM]);
$newattach = mapi_message_createattach($toMessage);
// Copy all attachments from old to new attachment
$attachprops = mapi_getprops($attach);
mapi_setprops($newattach, $attachprops);
if (isset($attachprops[mapi_prop_tag(PT_ERROR, mapi_prop_id(PR_ATTACH_DATA_BIN))])) {
// Data is in a stream
$srcstream = mapi_openpropertytostream($attach, PR_ATTACH_DATA_BIN);
$dststream = mapi_openpropertytostream($newattach, PR_ATTACH_DATA_BIN, MAPI_MODIFY | MAPI_CREATE);
while (1) {
$data = mapi_stream_read($srcstream, 4096);
if (strlen($data) == 0) {
break;
}
mapi_stream_write($dststream, $data);
}
mapi_stream_commit($dststream);
}
mapi_savechanges($newattach);
}
}
}
示例5: buildEMLAttachment
function buildEMLAttachment($attach)
{
$msgembedded = mapi_attach_openobj($attach);
$msgprops = mapi_getprops($msgembedded, array(PR_MESSAGE_CLASS, PR_CLIENT_SUBMIT_TIME, PR_DISPLAY_TO, PR_SUBJECT, PR_SENT_REPRESENTING_NAME, PR_SENT_REPRESENTING_EMAIL_ADDRESS));
$msgembeddedrcpttable = mapi_message_getrecipienttable($msgembedded);
$msgto = $msgprops[PR_DISPLAY_TO];
if ($msgembeddedrcpttable) {
$msgembeddedrecipients = mapi_table_queryrows($msgembeddedrcpttable, array(PR_ADDRTYPE, PR_ENTRYID, PR_DISPLAY_NAME, PR_EMAIL_ADDRESS, PR_SMTP_ADDRESS, PR_RECIPIENT_TYPE, PR_RECIPIENT_FLAGS, PR_PROPOSEDNEWTIME, PR_PROPOSENEWTIME_START, PR_PROPOSENEWTIME_END, PR_RECIPIENT_TRACKSTATUS), 0, 99999999);
foreach ($msgembeddedrecipients as $rcpt) {
if ($rcpt[PR_DISPLAY_NAME] == $msgprops[PR_DISPLAY_TO]) {
$msgto = $rcpt[PR_DISPLAY_NAME];
if (isset($rcpt[PR_EMAIL_ADDRESS]) && $rcpt[PR_EMAIL_ADDRESS] != $msgprops[PR_DISPLAY_TO]) {
$msgto .= " <" . $rcpt[PR_EMAIL_ADDRESS] . ">";
}
break;
}
}
}
$msgsubject = $msgprops[PR_SUBJECT];
$msgfrom = $msgprops[PR_SENT_REPRESENTING_NAME];
if (isset($msgprops[PR_SENT_REPRESENTING_EMAIL_ADDRESS]) && $msgprops[PR_SENT_REPRESENTING_EMAIL_ADDRESS] != $msgprops[PR_SENT_REPRESENTING_NAME]) {
$msgfrom .= " <" . $msgprops[PR_SENT_REPRESENTING_EMAIL_ADDRESS] . ">";
}
$msgtime = $msgprops[PR_CLIENT_SUBMIT_TIME];
$msgembeddedbody = eml_ReadMessage($msgembedded);
$msgembeddedattachtable = mapi_message_getattachmenttable($msgembedded);
$msgembeddedattachtablerows = mapi_table_queryallrows($msgembeddedattachtable, array(PR_ATTACH_NUM, PR_ATTACH_METHOD));
if ($msgembeddedattachtablerows) {
$boundary = '=_zpush_static';
$headercontenttype = "multipart/mixed";
$msgembeddedbody['body'] = "Unfortunately your mobile is not able to handle MIME Messages\n" . "--" . $boundary . "\n" . "Content-Type: " . $msgembeddedbody['content'] . "; charset=utf-8\n" . "Content-Transfer-Encoding: quoted-printable\n\n" . $msgembeddedbody['body'] . "\n";
foreach ($msgembeddedattachtablerows as $msgembeddedattachtablerow) {
$msgembeddedattach = mapi_message_openattach($msgembedded, $msgembeddedattachtablerow[PR_ATTACH_NUM]);
if (!$msgembeddedattach) {
debugLog("Unable to open attachment number {$attachnum}");
} else {
$msgembeddedattachprops = mapi_getprops($msgembeddedattach, array(PR_ATTACH_MIME_TAG, PR_ATTACH_LONG_FILENAME, PR_ATTACH_FILENAME, PR_DISPLAY_NAME));
if (isset($msgembeddedattachprops[PR_ATTACH_LONG_FILENAME])) {
$attachfilename = w2u($msgembeddedattachprops[PR_ATTACH_LONG_FILENAME]);
} else {
if (isset($msgembeddedattachprops[PR_ATTACH_FILENAME])) {
$attachfilename = w2u($msgembeddedattachprops[PR_ATTACH_FILENAME]);
} else {
if (isset($msgembeddedattachprops[PR_DISPLAY_NAME])) {
$attachfilename = w2u($msgembeddedattachprops[PR_DISPLAY_NAME]);
} else {
$attachfilename = w2u("untitled");
}
}
}
if ($msgembeddedattachtablerow[PR_ATTACH_METHOD] == ATTACH_EMBEDDED_MSG) {
$attachfilename .= w2u(".eml");
}
$msgembeddedbody['body'] .= "--" . $boundary . "\n" . "Content-Type: " . $msgembeddedattachprops[PR_ATTACH_MIME_TAG] . ";\n" . " name=\"" . $attachfilename . "\"\n" . "Content-Transfer-Encoding: base64\n" . "Content-Disposition: attachment;\n" . " filename=\"" . $attachfilename . "\"\n\n";
$msgembeddedattachstream = mapi_openpropertytostream($msgembeddedattach, PR_ATTACH_DATA_BIN);
$msgembeddedattachment = "";
while (1) {
$msgembeddedattachdata = mapi_stream_read($msgembeddedattachstream, 4096);
if (byte_strlen($msgembeddedattachdata) == 0) {
break;
}
$msgembeddedattachment .= $msgembeddedattachdata;
}
$msgembeddedbody['body'] .= chunk_split(base64_encode($msgembeddedattachment)) . "\n";
unset($msgembeddedattachment);
}
}
$msgembeddedbody['body'] .= "--" . $boundary . "--\n";
} else {
$headercontenttype = $msgembeddedbody['content'] . "; charset=utf-8";
$boundary = '';
}
$msgembeddedheader = "Subject: " . $msgsubject . "\n" . "From: " . $msgfrom . "\n" . "To: " . $msgto . "\n" . "Date: " . gmstrftime("%a, %d %b %Y %T +0000", $msgprops[PR_CLIENT_SUBMIT_TIME]) . "\n" . "MIME-Version: 1.0\n" . "Content-Type: " . $headercontenttype . ";\n" . ($boundary ? " boundary=\"" . $boundary . "\"\n" : "") . "\n";
$stream = mapi_stream_create();
mapi_stream_setsize($stream, byte_strlen($msgembeddedheader . $msgembeddedbody['body']));
mapi_stream_write($stream, $msgembeddedheader . $msgembeddedbody['body']);
mapi_stream_seek($stream, 0, STREAM_SEEK_SET);
return $stream;
}
示例6: SendMail
//.........这里部分代码省略.........
$fwbody = "";
while (1) {
$data = mapi_stream_read($stream, 1024);
if (strlen($data) == 0) {
break;
}
$fwbody .= $data;
}
$stream = mapi_openproperty($fwmessage, PR_HTML, IID_IStream, 0, 0);
$fwbody_html = "";
while (1) {
$data = mapi_stream_read($stream, 1024);
if (strlen($data) == 0) {
break;
}
$fwbody_html .= $data;
}
if ($forward) {
// During a forward, we have to add the forward header ourselves. This is because
// normally the forwarded message is added as an attachment. However, we don't want this
// because it would be rather complicated to copy over the entire original message due
// to the lack of IMessage::CopyTo ..
$fwmessageprops = mapi_getprops($fwmessage, array(PR_SENT_REPRESENTING_NAME, PR_DISPLAY_TO, PR_DISPLAY_CC, PR_SUBJECT, PR_CLIENT_SUBMIT_TIME));
$fwheader = "\r\n\r\n";
$fwheader .= "-----Original Message-----\r\n";
if (isset($fwmessageprops[PR_SENT_REPRESENTING_NAME])) {
$fwheader .= "From: " . $fwmessageprops[PR_SENT_REPRESENTING_NAME] . "\r\n";
}
if (isset($fwmessageprops[PR_DISPLAY_TO]) && strlen($fwmessageprops[PR_DISPLAY_TO]) > 0) {
$fwheader .= "To: " . $fwmessageprops[PR_DISPLAY_TO] . "\r\n";
}
if (isset($fwmessageprops[PR_DISPLAY_CC]) && strlen($fwmessageprops[PR_DISPLAY_CC]) > 0) {
$fwheader .= "Cc: " . $fwmessageprops[PR_DISPLAY_CC] . "\r\n";
}
if (isset($fwmessageprops[PR_CLIENT_SUBMIT_TIME])) {
$fwheader .= "Sent: " . strftime("%x %X", $fwmessageprops[PR_CLIENT_SUBMIT_TIME]) . "\r\n";
}
if (isset($fwmessageprops[PR_SUBJECT])) {
$fwheader .= "Subject: " . $fwmessageprops[PR_SUBJECT] . "\r\n";
}
$fwheader .= "\r\n";
// add fwheader to body and body_html
$body .= $fwheader;
if (strlen($body_html) > 0) {
$body_html .= str_ireplace("\r\n", "<br>", $fwheader);
}
}
if (strlen($body) > 0) {
$body .= $fwbody;
}
if (strlen($body_html) > 0) {
$body_html .= $fwbody_html;
}
} else {
debugLog("Unable to open item with id {$orig} for forward/reply");
}
}
if ($forward) {
// Add attachments from the original message in a forward
$entryid = mapi_msgstore_entryidfromsourcekey($this->_defaultstore, hex2bin($parent), hex2bin($orig));
$fwmessage = mapi_msgstore_openentry($this->_defaultstore, $entryid);
$attachtable = mapi_message_getattachmenttable($fwmessage);
$rows = mapi_table_queryallrows($attachtable, array(PR_ATTACH_NUM));
foreach ($rows as $row) {
if (isset($row[PR_ATTACH_NUM])) {
$attach = mapi_message_openattach($fwmessage, $row[PR_ATTACH_NUM]);
$newattach = mapi_message_createattach($mapimessage);
// Copy all attachments from old to new attachment
$attachprops = mapi_getprops($attach);
mapi_setprops($newattach, $attachprops);
if (isset($attachprops[mapi_prop_tag(PT_ERROR, mapi_prop_id(PR_ATTACH_DATA_BIN))])) {
// Data is in a stream
$srcstream = mapi_openpropertytostream($attach, PR_ATTACH_DATA_BIN);
$dststream = mapi_openpropertytostream($newattach, PR_ATTACH_DATA_BIN, MAPI_MODIFY | MAPI_CREATE);
while (1) {
$data = mapi_stream_read($srcstream, 4096);
if (strlen($data) == 0) {
break;
}
mapi_stream_write($dststream, $data);
}
mapi_stream_commit($dststream);
}
mapi_savechanges($newattach);
}
}
}
//set PR_INTERNET_CPID to 65001 (utf-8) if store supports it and to 1252 otherwise
$internetcpid = 1252;
if (defined('STORE_SUPPORTS_UNICODE') && STORE_SUPPORTS_UNICODE == true) {
$internetcpid = 65001;
}
mapi_setprops($mapimessage, array(PR_BODY => $body, PR_INTERNET_CPID => $internetcpid));
if (strlen($body_html) > 0) {
mapi_setprops($mapimessage, array(PR_HTML => $body_html));
}
mapi_savechanges($mapimessage);
mapi_message_submitmessage($mapimessage);
return true;
}
示例7: SendMail
//.........这里部分代码省略.........
$this->_storeAttachment($mapimessage, $part);
}
}
} else {
$body = u2w($message->body);
}
if ($forward) {
$orig = $forward;
}
if ($reply) {
$orig = $reply;
}
if (isset($orig) && $orig) {
// Append the original text body for reply/forward
$entryid = mapi_msgstore_entryidfromsourcekey($this->_defaultstore, hex2bin($parent), hex2bin($orig));
$fwmessage = mapi_msgstore_openentry($this->_defaultstore, $entryid);
if ($fwmessage) {
//update icon when forwarding or replying message
if ($forward) {
mapi_setprops($fwmessage, array(PR_ICON_INDEX => 262));
} elseif ($reply) {
mapi_setprops($fwmessage, array(PR_ICON_INDEX => 261));
}
mapi_savechanges($fwmessage);
$stream = mapi_openproperty($fwmessage, PR_BODY, IID_IStream, 0, 0);
$fwbody = "";
while (1) {
$data = mapi_stream_read($stream, 1024);
if (strlen($data) == 0) {
break;
}
$fwbody .= $data;
}
if (strlen($body) > 0) {
if ($forward) {
// During a forward, we have to add the forward header ourselves. This is because
// normally the forwarded message is added as an attachment. However, we don't want this
// because it would be rather complicated to copy over the entire original message due
// to the lack of IMessage::CopyTo ..
$fwmessageprops = mapi_getprops($fwmessage, array(PR_SENT_REPRESENTING_NAME, PR_DISPLAY_TO, PR_DISPLAY_CC, PR_SUBJECT, PR_CLIENT_SUBMIT_TIME));
$body .= "\r\n\r\n";
$body .= "-----Original Message-----\r\n";
if (isset($fwmessageprops[PR_SENT_REPRESENTING_NAME])) {
$body .= "From: " . $fwmessageprops[PR_SENT_REPRESENTING_NAME] . "\r\n";
}
if (isset($fwmessageprops[PR_DISPLAY_TO]) && strlen($fwmessageprops[PR_DISPLAY_TO]) > 0) {
$body .= "To: " . $fwmessageprops[PR_DISPLAY_TO] . "\r\n";
}
if (isset($fwmessageprops[PR_DISPLAY_CC]) && strlen($fwmessageprops[PR_DISPLAY_CC]) > 0) {
$body .= "Cc: " . $fwmessageprops[PR_DISPLAY_CC] . "\r\n";
}
if (isset($fwmessageprops[PR_CLIENT_SUBMIT_TIME])) {
$body .= "Sent: " . strftime("%x %X", $fwmessageprops[PR_CLIENT_SUBMIT_TIME]) . "\r\n";
}
if (isset($fwmessageprops[PR_SUBJECT])) {
$body .= "Subject: " . $fwmessageprops[PR_SUBJECT] . "\r\n";
}
$body .= "\r\n";
}
$body .= $fwbody;
}
} else {
debugLog("Unable to open item with id {$orig} for forward/reply");
}
}
if ($forward) {
// Add attachments from the original message in a forward
$entryid = mapi_msgstore_entryidfromsourcekey($this->_defaultstore, hex2bin($parent), hex2bin($orig));
$fwmessage = mapi_msgstore_openentry($this->_defaultstore, $entryid);
$attachtable = mapi_message_getattachmenttable($fwmessage);
$rows = mapi_table_queryallrows($attachtable, array(PR_ATTACH_NUM));
foreach ($rows as $row) {
if (isset($row[PR_ATTACH_NUM])) {
$attach = mapi_message_openattach($fwmessage, $row[PR_ATTACH_NUM]);
$newattach = mapi_message_createattach($mapimessage);
// Copy all attachments from old to new attachment
$attachprops = mapi_getprops($attach);
mapi_setprops($newattach, $attachprops);
if (isset($attachprops[mapi_prop_tag(PT_ERROR, mapi_prop_id(PR_ATTACH_DATA_BIN))])) {
// Data is in a stream
$srcstream = mapi_openpropertytostream($attach, PR_ATTACH_DATA_BIN);
$dststream = mapi_openpropertytostream($newattach, PR_ATTACH_DATA_BIN, MAPI_MODIFY | MAPI_CREATE);
while (1) {
$data = mapi_stream_read($srcstream, 4096);
if (strlen($data) == 0) {
break;
}
mapi_stream_write($dststream, $data);
}
mapi_stream_commit($dststream);
}
mapi_savechanges($newattach);
}
}
}
mapi_setprops($mapimessage, array(PR_BODY => $body));
mapi_savechanges($mapimessage);
mapi_message_submitmessage($mapimessage);
return true;
}
示例8: getExceptionAttachment
/**
* Get an exception attachment based on its basedate
*/
function getExceptionAttachment($base_date)
{
// Retrieve only exceptions which are stored as embedded messages
$attach_res = array(RES_AND, array(array(RES_PROPERTY, array(RELOP => RELOP_EQ, ULPROPTAG => PR_ATTACH_METHOD, VALUE => array(PR_ATTACH_METHOD => ATTACH_EMBEDDED_MSG)))));
$attachments = mapi_message_getattachmenttable($this->message);
$attachRows = mapi_table_queryallrows($attachments, array(PR_ATTACH_NUM), $attach_res);
if (is_array($attachRows)) {
foreach ($attachRows as $attachRow) {
$tempattach = mapi_message_openattach($this->message, $attachRow[PR_ATTACH_NUM]);
$exception = mapi_attach_openobj($tempattach);
$data = mapi_message_getprops($exception, array($this->proptags["basedate"]));
if (!isset($data[$this->proptags["basedate"]])) {
// if no basedate found then it could be embedded message so ignore it
// we need proper restriction to exclude embedded messages aswell
continue;
}
if ($this->isSameDay($this->fromGMT($this->tz, $data[$this->proptags["basedate"]]), $base_date)) {
return $tempattach;
}
}
}
return false;
}
示例9: propertiesToVObject
//.........这里部分代码省略.........
if (isset($contactProperties[$p['birthday']]) && $contactProperties[$p['birthday']] > 0) {
$vCard->add('BDAY', date(DATE_PATTERN, $contactProperties[$p['birthday']]));
}
if (isset($contactProperties[$p['wedding_anniversary']]) && $contactProperties[$p['wedding_anniversary']] > 0) {
if ($this->version >= 4) {
$vCard->add('ANNIVERSARY', date(DATE_PATTERN, $contactProperties[$p['wedding_anniversary']]));
} else {
$vCard->add('X-ANNIVERSARY', date(DATE_PATTERN, $contactProperties[$p['wedding_anniversary']]));
}
}
// Telephone numbers
// webaccess can handle 19 telephone numbers...
$this->setVCard($vCard, 'TEL;TYPE=HOME,VOICE', $contactProperties, $p['home_telephone_number']);
$this->setVCard($vCard, 'TEL;TYPE=HOME,VOICE', $contactProperties, $p['home2_telephone_number']);
$this->setVCard($vCard, 'TEL;TYPE=CELL', $contactProperties, $p['cellular_telephone_number']);
$this->setVCard($vCard, 'TEL;TYPE=WORK,VOICE', $contactProperties, $p['office_telephone_number']);
$this->setVCard($vCard, 'TEL;TYPE=WORK,VOICE', $contactProperties, $p['business2_telephone_number']);
$this->setVCard($vCard, 'TEL;TYPE=WORK,FAX', $contactProperties, $p['business_fax_number']);
$this->setVCard($vCard, 'TEL;TYPE=HOME,FAX', $contactProperties, $p['home_fax_number']);
$this->setVCard($vCard, 'TEL;TYPE=PAGER', $contactProperties, $p['pager_telephone_number']);
$this->setVCard($vCard, 'TEL;TYPE=ISDN', $contactProperties, $p['isdn_number']);
$this->setVCard($vCard, 'TEL;TYPE=WORK', $contactProperties, $p['company_telephone_number']);
$this->setVCard($vCard, 'TEL;TYPE=CAR', $contactProperties, $p['car_telephone_number']);
$this->setVCard($vCard, 'TEL;TYPE=SECR', $contactProperties, $p['assistant_telephone_number']);
// There are unmatched telephone numbers in zarafa, use them!
$unmatchedProperties = array("callback_telephone_number", "other_telephone_number", "primary_fax_number", "primary_telephone_number", "radio_telephone_number", "telex_telephone_number", "ttytdd_telephone_number");
if (in_array(DEFAULT_TELEPHONE_NUMBER_PROPERTY, $unmatchedProperties)) {
// unmatched found a match!
$this->setVCard($vCard, 'TEL', $contactProperties, $p[DEFAULT_TELEPHONE_NUMBER_PROPERTY]);
}
$this->setVCardAddress($vCard, 'HOME', $contactProperties, 'home');
$this->setVCardAddress($vCard, 'WORK', $contactProperties, 'business');
$this->setVCardAddress($vCard, 'OTHER', $contactProperties, 'other');
// emails
for ($i = 1; $i <= 3; $i++) {
if (isset($contactProperties[$p["email_address_{$i}"]])) {
// Zarafa needs an email display name
$emailProperty = new Sabre_VObject_Property('EMAIL', $contactProperties[$p["email_address_{$i}"]]);
// Get display name
$dn = isset($contactProperties[$p["email_address_display_name_{$i}"]]) ? $contactProperties[$p["email_address_display_name_{$i}"]] : $contactProperties[$p['display_name']];
$emailProperty->offsetSet("X-CN", '"' . $dn . '"');
$vCard->add($emailProperty);
}
}
// URL and Instant Messenging (vCard 3.0 extension)
$this->setVCard($vCard, 'URL', $contactProperties, $p["webpage"]);
$this->setVCard($vCard, 'IMPP', $contactProperties, $p["im"]);
// Categories
$contactCategories = '';
if (isset($contactProperties[$p['categories']])) {
if (is_array($contactProperties[$p['categories']])) {
$contactCategories = implode(',', $contactProperties[$p['categories']]);
} else {
$contactCategories = $contactProperties[$p['categories']];
}
}
if ($contactCategories != '') {
$vCard->add('CATEGORIES', $contactCategories);
}
// Contact picture?
$hasattachProp = mapi_getprops($contact, array(PR_HASATTACH));
$photo = NULL;
$photoMime = '';
if (isset($hasattachProp[PR_HASATTACH]) && $hasattachProp[PR_HASATTACH]) {
$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));
$dump = print_r($attachments, true);
$this->logger->trace("Contact attachments:\n{$dump}");
foreach ($attachments as $attachmentRow) {
if (isset($attachmentRow[PR_ATTACHMENT_CONTACTPHOTO]) && $attachmentRow[PR_ATTACHMENT_CONTACTPHOTO]) {
$attach = mapi_message_openattach($contact, $attachmentRow[PR_ATTACH_NUM]);
$photo = mapi_attach_openbin($attach, PR_ATTACH_DATA_BIN);
if (isset($attachmentRow[PR_ATTACH_MIME_TAG])) {
$photoMime = $attachmentRow[PR_ATTACH_MIME_TAG];
} else {
$photoMime = 'image/jpeg';
}
break;
}
}
}
if ($photo != NULL) {
// SogoConnector does not like image/jpeg
if ($photoMime == 'image/jpeg') {
$photoMime = 'JPEG';
}
$this->logger->trace("Adding contact picture to VCard");
$photoEncoded = base64_encode($photo);
$photoProperty = new Sabre_VObject_Property('PHOTO', $photoEncoded);
$photoProperty->offsetSet('TYPE', $photoMime);
$photoProperty->offsetSet('ENCODING', 'b');
$vCard->add($photoProperty);
}
// Misc
$vCard->add('UID', "urn:uuid:" . substr($contactProperties[PR_CARDDAV_URI], 0, -4));
// $this->entryIdToStr($contactProperties[PR_ENTRYID]));
$this->setVCard($vCard, 'NOTE', $contactProperties, $p['notes']);
$vCard->add('PRODID', VCARD_PRODUCT_ID);
$vCard->add('REV', date('c', $contactProperties[$p['last_modification_time']]));
}
示例10: GetAttachmentData
function GetAttachmentData($attname)
{
list($folderid, $id, $attachnum) = explode(":", $attname);
if (!isset($id) || !isset($attachnum)) {
return false;
}
$sourcekey = hex2bin($id);
$foldersourcekey = hex2bin($folderid);
$entryid = mapi_msgstore_entryidfromsourcekey($this->_defaultstore, $foldersourcekey, $sourcekey);
if (!$entryid) {
debugLog("Attachment requested for non-existing item {$attname}");
return false;
}
$message = mapi_msgstore_openentry($this->_defaultstore, $entryid);
if (!$message) {
debugLog("Unable to open item for attachment data for " . bin2hex($entryid));
return false;
}
$attach = mapi_message_openattach($message, $attachnum);
if (!$attach) {
debugLog("Unable to open attachment number {$attachnum}");
return false;
}
$attachtable = mapi_message_getattachmenttable($message);
// START CHANGED dw2412 EML Attachment
$rows = mapi_table_queryallrows($attachtable, array(PR_ATTACH_NUM, PR_ATTACH_METHOD));
foreach ($rows as $row) {
if (isset($row[PR_ATTACH_NUM]) && $row[PR_ATTACH_NUM] == $attachnum) {
if ($row[PR_ATTACH_METHOD] == ATTACH_EMBEDDED_MSG) {
$stream = buildEMLAttachment($attach);
} else {
$stream = mapi_openpropertytostream($attach, PR_ATTACH_DATA_BIN);
}
}
}
// END CHANGED dw2412 EML Attachment
if (!$stream) {
debugLog("Unable to open attachment data stream");
return false;
}
while (1) {
$data = mapi_stream_read($stream, 4096);
if (strlen($data) == 0) {
break;
}
print $data;
}
return true;
}
示例11: SendMail
//.........这里部分代码省略.........
if (isset($part->ctype_parameters["name"])) {
$filename = $part->ctype_parameters["name"];
} else {
if (isset($part->d_parameters["name"])) {
$filename = $part->d_parameters["filename"];
} else {
$filename = "untitled";
}
}
// Set filename and attachment type
mapi_setprops($attach, array(PR_ATTACH_LONG_FILENAME => u2w($filename), PR_ATTACH_METHOD => ATTACH_BY_VALUE));
// Set attachment data
mapi_setprops($attach, array(PR_ATTACH_DATA_BIN => $part->body));
// Set MIME type
mapi_setprops($attach, array(PR_ATTACH_MIME_TAG => $part->ctype_primary . "/" . $part->ctype_secondary));
mapi_savechanges($attach);
}
}
} else {
$body = u2w($message->body);
}
if ($forward) {
$orig = $forward;
}
if ($reply) {
$orig = $reply;
}
if (isset($orig) && $orig) {
// Append the original text body for reply/forward
$entryid = mapi_msgstore_entryidfromsourcekey($this->_defaultstore, hex2bin($parent), hex2bin($orig));
$fwmessage = mapi_msgstore_openentry($this->_defaultstore, $entryid);
if ($fwmessage) {
$messageprops = mapi_getprops($fwmessage, array(PR_BODY));
if (isset($messageprops[PR_BODY])) {
if ($forward) {
// During a forward, we have to add the forward header ourselves. This is because
// normally the forwarded message is added as an attachment. However, we don't want this
// because it would be rather complicated to copy over the entire original message due
// to the lack of IMessage::CopyTo ..
$fwmessageprops = mapi_getprops($fwmessage, array(PR_SENT_REPRESENTING_NAME, PR_DISPLAY_TO, PR_DISPLAY_CC, PR_SUBJECT, PR_CLIENT_SUBMIT_TIME));
$body .= "\r\n\r\n";
$body .= "-----Original Message-----\r\n";
if (isset($fwmessageprops[PR_SENT_REPRESENTING_NAME])) {
$body .= "From: " . $fwmessageprops[PR_SENT_REPRESENTING_NAME] . "\r\n";
}
if (isset($fwmessageprops[PR_DISPLAY_TO]) && strlen($fwmessageprops[PR_DISPLAY_TO]) > 0) {
$body .= "To: " . $fwmessageprops[PR_DISPLAY_TO] . "\r\n";
}
if (isset($fwmessageprops[PR_DISPLAY_CC]) && strlen($fwmessageprops[PR_DISPLAY_CC]) > 0) {
$body .= "Cc: " . $fwmessageprops[PR_DISPLAY_CC] . "\r\n";
}
if (isset($fwmessageprops[PR_CLIENT_SUBMIT_TIME])) {
$body .= "Sent: " . strftime("%x %X", $fwmessageprops[PR_CLIENT_SUBMIT_TIME]) . "\r\n";
}
if (isset($fwmessageprops[PR_SUBJECT])) {
$body .= "Subject: " . $fwmessageprops[PR_SUBJECT] . "\r\n";
}
$body .= "\r\n";
}
$body .= $messageprops[PR_BODY];
}
} else {
debugLog("Unable to open item with id {$orig} for forward/reply");
}
}
if ($forward) {
// Add attachments from the original message in a forward
$entryid = mapi_msgstore_entryidfromsourcekey($this->_defaultstore, hex2bin($parent), hex2bin($orig));
$fwmessage = mapi_msgstore_openentry($this->_defaultstore, $entryid);
$attachtable = mapi_message_getattachmenttable($fwmessage);
$rows = mapi_table_queryallrows($attachtable, array(PR_ATTACH_NUM));
foreach ($rows as $row) {
if (isset($row[PR_ATTACH_NUM])) {
$attach = mapi_message_openattach($fwmessage, $row[PR_ATTACH_NUM]);
$newattach = mapi_message_createattach($mapimessage);
// Copy all attachments from old to new attachment
$attachprops = mapi_getprops($attach);
mapi_setprops($newattach, $attachprops);
if (isset($attachprops[mapi_prop_tag(PT_ERROR, mapi_prop_id(PR_ATTACH_DATA_BIN))])) {
// Data is in a stream
$srcstream = mapi_openpropertytostream($attach, PR_ATTACH_DATA_BIN);
$dststream = mapi_openpropertytostream($newattach, PR_ATTACH_DATA_BIN, MAPI_MODIFY | MAPI_CREATE);
while (1) {
$data = mapi_stream_read($srcstream, 4096);
if (strlen($data) == 0) {
break;
}
mapi_stream_write($dststream, $data);
}
mapi_stream_commit($dststream);
}
mapi_savechanges($newattach);
}
}
}
mapi_setprops($mapimessage, array(PR_BODY => $body));
mapi_savechanges($mapimessage);
mapi_message_submitmessage($mapimessage);
return true;
}
示例12: copyAttachments
/**
* Copies attachments from one message to another.
*
* @param MAPIMessage $toMessage
* @param MAPIMessage $fromMessage
*
* @return void
*/
private function copyAttachments(&$toMessage, $fromMessage)
{
$attachtable = mapi_message_getattachmenttable($fromMessage);
$rows = mapi_table_queryallrows($attachtable, array(PR_ATTACH_NUM));
foreach ($rows as $row) {
if (isset($row[PR_ATTACH_NUM])) {
$attach = mapi_message_openattach($fromMessage, $row[PR_ATTACH_NUM]);
$newattach = mapi_message_createattach($toMessage);
mapi_copyto($attach, array(), array(), $newattach, 0);
mapi_savechanges($newattach);
}
}
}
示例13: setContactPicture
/**
* 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");
}
}
示例14: imtoinet
/**
* A wrapper for mapi_inetmapi_imtoinet function
*
* @param MAPIMessage $mapimessage
* @param SyncObject $message
*
* @access private
* @return boolean
*/
private function imtoinet($mapimessage, &$message)
{
// if it is a signed message get a full attachment generated by ZCP
$props = mapi_getprops($mapimessage, array(PR_MESSAGE_CLASS));
if (isset($props[PR_MESSAGE_CLASS]) && $props[PR_MESSAGE_CLASS] && strpos(strtolower($props[PR_MESSAGE_CLASS]), 'multipartsigned')) {
// find the required attachment
$attachtable = mapi_message_getattachmenttable($mapimessage);
mapi_table_restrict($attachtable, MAPIUtils::GetSignedAttachmentRestriction());
if (mapi_table_getrowcount($attachtable) == 1) {
$rows = mapi_table_queryrows($attachtable, array(PR_ATTACH_NUM, PR_ATTACH_SIZE), 0, 1);
if (isset($rows[0][PR_ATTACH_NUM])) {
$mapiattach = mapi_message_openattach($mapimessage, $rows[0][PR_ATTACH_NUM]);
$stream = mapi_openpropertytostream($mapiattach, PR_ATTACH_DATA_BIN);
$streamsize = $rows[0][PR_ATTACH_SIZE];
}
}
} elseif (function_exists("mapi_inetmapi_imtoinet")) {
$addrbook = $this->getAddressbook();
$stream = mapi_inetmapi_imtoinet($this->session, $addrbook, $mapimessage, array('use_tnef' => -1));
$mstreamstat = mapi_stream_stat($stream);
$streamsize = $mstreamstat["cb"];
}
if (isset($stream) && isset($streamsize)) {
if (Request::GetProtocolVersion() >= 12.0) {
if (!isset($message->asbody)) {
$message->asbody = new SyncBaseBody();
}
//TODO data should be wrapped in a MapiStreamWrapper
$message->asbody->data = mapi_stream_read($stream, $streamsize);
$message->asbody->estimatedDataSize = $streamsize;
$message->asbody->truncated = 0;
} else {
$message->mimetruncated = 0;
//TODO mimedata should be a wrapped in a MapiStreamWrapper
$message->mimedata = mapi_stream_read($stream, $streamsize);
$message->mimesize = $streamsize;
}
unset($message->body, $message->bodytruncated);
return true;
} else {
ZLog::Write(LOGLEVEL_ERROR, sprintf("Error opening attachment for imtoinet"));
}
return false;
}
示例15: getEmbeddedTask
function getEmbeddedTask($message)
{
$table = mapi_message_getattachmenttable($message);
$rows = mapi_table_queryallrows($table, array(PR_ATTACH_NUM));
// Assume only one attachment
if (empty($rows)) {
return false;
}
$attach = mapi_message_openattach($message, $rows[0][PR_ATTACH_NUM]);
$message = mapi_openproperty($attach, PR_ATTACH_DATA_OBJ, IID_IMessage, 0, 0);
return $message;
}