本文整理匯總了PHP中mapi_stream_write函數的典型用法代碼示例。如果您正苦於以下問題:PHP mapi_stream_write函數的具體用法?PHP mapi_stream_write怎麽用?PHP mapi_stream_write使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了mapi_stream_write函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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);
}
}
}
示例3: Config
/**
* Initializes the importer
*
* @param string $state
* @param int $flags
*
* @access public
* @return boolean
* @throws StatusException
*/
public function Config($state, $flags = 0)
{
$this->flags = $flags;
// this should never happen
if ($this->importer === false) {
throw new StatusException("ImportChangesICS->Config(): Error, importer not available", SYNC_FSSTATUS_CODEUNKNOWN, null, LOGLEVEL_ERROR);
}
// Put the state information in a stream that can be used by ICS
$stream = mapi_stream_create();
if (strlen($state) == 0) {
$state = hex2bin("0000000000000000");
}
ZLog::Write(LOGLEVEL_DEBUG, sprintf("ImportChangesICS->Config(): initializing importer with state: 0x%s", bin2hex($state)));
mapi_stream_write($stream, $state);
$this->statestream = $stream;
if ($this->folderid !== false) {
// possible conflicting messages will be cached here
$this->memChanges = new ChangesMemoryWrapper();
$stat = mapi_importcontentschanges_config($this->importer, $stream, $flags);
} else {
$stat = mapi_importhierarchychanges_config($this->importer, $stream, $flags);
}
if (!$stat) {
throw new StatusException(sprintf("ImportChangesICS->Config(): Error, mapi_import_*_changes_config() failed: 0x%X", mapi_last_hresult()), SYNC_FSSTATUS_CODEUNKNOWN, null, LOGLEVEL_WARN);
}
return $stat;
}
示例4: 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;
}
示例5: 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;
}
示例6: Config
/**
* Configures the exporter
*
* @param string $state
* @param int $flags
*
* @access public
* @return boolean
* @throws StatusException
*/
public function Config($state, $flags = 0)
{
$this->exporterflags = 0;
$this->flags = $flags;
// this should never happen
if ($this->exporter === false || is_array($state)) {
throw new StatusException("ExportChangesICS->Config(): Error, exporter not available", SYNC_FSSTATUS_CODEUNKNOWN, null, LOGLEVEL_ERROR);
}
// change exporterflags if we are doing a ContentExport
if ($this->folderid) {
$this->exporterflags |= SYNC_NORMAL | SYNC_READ_STATE;
// Initial sync, we don't want deleted items. If the initial sync is chunked
// we check the change ID of the syncstate (0 at initial sync)
// On subsequent syncs, we do want to receive delete events.
if (strlen($state) == 0 || bin2hex(substr($state, 4, 4)) == "00000000") {
if (!($this->flags & BACKEND_DISCARD_DATA)) {
ZLog::Write(LOGLEVEL_DEBUG, "ExportChangesICS->Config(): synching inital data");
}
$this->exporterflags |= SYNC_NO_SOFT_DELETIONS | SYNC_NO_DELETIONS;
}
}
if ($this->flags & BACKEND_DISCARD_DATA) {
$this->exporterflags |= SYNC_CATCHUP;
}
// Put the state information in a stream that can be used by ICS
$stream = mapi_stream_create();
if (strlen($state) == 0) {
$state = hex2bin("0000000000000000");
}
if (!($this->flags & BACKEND_DISCARD_DATA)) {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("ExportChangesICS->Config() initialized with state: 0x%s", bin2hex($state)));
}
mapi_stream_write($stream, $state);
$this->statestream = $stream;
}
示例7: sendResponse
function sendResponse($type, $prefix)
{
// Create a message in our outbox
$outgoing = $this->createOutgoingMessage();
$messageprops = mapi_getprops($this->message, array(PR_SUBJECT));
$attach = mapi_message_createattach($outgoing);
mapi_setprops($attach, array(PR_ATTACH_METHOD => ATTACH_EMBEDDED_MSG, PR_DISPLAY_NAME => $messageprops[PR_SUBJECT], PR_ATTACHMENT_HIDDEN => true));
$sub = mapi_attach_openproperty($attach, PR_ATTACH_DATA_OBJ, IID_IMessage, 0, MAPI_CREATE | MAPI_MODIFY);
mapi_copyto($this->message, array(), array(PR_SENT_REPRESENTING_NAME, PR_SENT_REPRESENTING_EMAIL_ADDRESS, PR_SENT_REPRESENTING_ADDRTYPE, PR_SENT_REPRESENTING_ENTRYID, PR_SENT_REPRESENTING_SEARCH_KEY), $outgoing);
mapi_copyto($this->message, array(), array(), $sub);
if (!$this->setRecipientsForResponse($outgoing, $type)) {
return false;
}
switch ($type) {
case tdmtTaskAcc:
$messageclass = "IPM.TaskRequest.Accept";
break;
case tdmtTaskDec:
$messageclass = "IPM.TaskRequest.Decline";
break;
case tdmtTaskUpd:
$messageclass = "IPM.TaskRequest.Update";
break;
}
mapi_savechanges($sub);
mapi_savechanges($attach);
// Set Body
$body = $this->getBody();
$stream = mapi_openpropertytostream($outgoing, PR_BODY, MAPI_CREATE | MAPI_MODIFY);
mapi_stream_setsize($stream, strlen($body));
mapi_stream_write($stream, $body);
mapi_stream_commit($stream);
// Set subject, taskmode, message class, icon index, response time
mapi_setprops($outgoing, array(PR_SUBJECT => $prefix . $messageprops[PR_SUBJECT], $this->props['taskmode'] => $type, PR_MESSAGE_CLASS => $messageclass, PR_ICON_INDEX => 0xffffffff, $this->props['assignedtime'] => time()));
mapi_savechanges($outgoing);
mapi_message_submitmessage($outgoing);
return true;
}
示例8: 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;
}
示例9: SendMail
//.........這裏部分代碼省略.........
$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 ($smartdata['task'] == 'forward') {
// Add attachments from the original message in a forward
if (isset($smartdata['longid'])) {
$entryid = hex2bin($smartdata['longid']);
} else {
$entryid = mapi_msgstore_entryidfromsourcekey($this->_defaultstore, hex2bin($smartdata['folderid']), hex2bin($smartdata['itemid']));
}
$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);
}
}
}
// START ADDED dw2412 update/create conversation index
if (CONVERSATIONINDEX == true) {
$ci = new ConversationIndex();
if ($conversationindex) {
$ci->Decode($conversationindex);
$ci->Update();
} else {
$ci->Create();
}
mapi_setprops($mapimessage, array(PR_CONVERSATION_INDEX => $ci->Encode()));
}
// END ADDED dw2412 update/create conversation index
//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));
}
if (mapi_savechanges($mapimessage) === false || mapi_message_submitmessage($mapimessage) === false) {
switch ($smartdata['task']) {
case 'reply':
debugLog("Sendmail: Message reply failed, sending failed at all");
return 121;
default:
debugLog("Sendmail: Message failed to be saved/submitted, sending failed at all");
return 120;
}
}
return true;
}
示例10: 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;
}