本文整理汇总了PHP中mapi_prop_id函数的典型用法代码示例。如果您正苦于以下问题:PHP mapi_prop_id函数的具体用法?PHP mapi_prop_id怎么用?PHP mapi_prop_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mapi_prop_id函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getError
/**
* Returns the error code for a given property. Helper for getNativeBodyType function.
*
* @param int $tag
* @param array $messageprops
*
* @access private
* @return int (MAPI_ERROR_CODE)
*/
private function getError($tag, $messageprops)
{
$prBodyError = mapi_prop_tag(PT_ERROR, mapi_prop_id($tag));
if (isset($messageprops[$prBodyError]) && mapi_is_error($messageprops[$prBodyError])) {
if ($messageprops[$prBodyError] == MAPI_E_NOT_ENOUGH_MEMORY_32BIT || $messageprops[$prBodyError] == MAPI_E_NOT_ENOUGH_MEMORY_64BIT) {
return MAPI_E_NOT_ENOUGH_MEMORY;
}
}
return MAPI_E_NOT_FOUND;
}
示例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: readSingleMapiProp
/**
* Reads a single mapi prop.
*
* @param string &$buffer
* @param int $size
* @param mixed &$read
* @param array &$mapiprops
*
* @access private
* @return int
*/
private function readSingleMapiProp(&$buffer, &$size, &$read, &$mapiprops)
{
$propTag = 0;
$len = 0;
$origSize = $size;
$isNamedId = 0;
$namedProp = 0;
$count = 0;
$mvProp = 0;
$guid = 0;
if ($size < 8) {
return MAPI_E_NOT_FOUND;
}
$hresult = $this->readFromTnefStream($buffer, self::DWORD, $propTag);
if ($hresult !== NOERROR) {
ZLog::Write(LOGLEVEL_WARN, "TNEF: There was an error reading a mapi property tag from the stream.");
return $hresult;
}
$size -= 4;
ZLog::Write(LOGLEVEL_DEBUG, "TNEF: mapi prop type:" . dechex(mapi_prop_type($propTag)));
ZLog::Write(LOGLEVEL_DEBUG, "TNEF: mapi prop tag: 0x" . sprintf("%04x", mapi_prop_id($propTag)));
if (mapi_prop_id($propTag) >= 0x8000) {
// Named property, first read GUID, then name/id
if ($size < 24) {
ZLog::Write(LOGLEVEL_WARN, "TNEF: Corrupt guid size for named property:" . dechex($propTag));
return MAPI_E_CORRUPT_DATA;
}
//strip GUID & name/id
$hresult = $this->readBuffer($buffer, 16, $guid);
if ($hresult !== NOERROR) {
ZLog::Write(LOGLEVEL_WARN, "TNEF: There was an error reading stream property buffer");
return $hresult;
}
$size -= 16;
//it is not used and is here only for eventual debugging
$readableGuid = unpack("VV/v2v/n4n", $guid);
$readableGuid = sprintf("{%08x-%04x-%04x-%04x-%04x%04x%04x}", $readableGuid['V'], $readableGuid['v1'], $readableGuid['v2'], $readableGuid['n1'], $readableGuid['n2'], $readableGuid['n3'], $readableGuid['n4']);
ZLog::Write(LOGLEVEL_DEBUG, "TNEF: guid:{$readableGuid}");
$hresult = $this->readFromTnefStream($buffer, self::DWORD, $isNamedId);
if ($hresult !== NOERROR) {
ZLog::Write(LOGLEVEL_WARN, "TNEF: There was an error reading stream property checksum.");
return $hresult;
}
$size -= 4;
if ($isNamedId != 0) {
// A string name follows
//read length of the property
$hresult = $this->readFromTnefStream($buffer, self::DWORD, $len);
if ($hresult !== NOERROR) {
ZLog::Write(LOGLEVEL_WARN, "TNEF: There was an error reading mapi property's length");
return $hresult;
}
$size -= 4;
if ($size < $len) {
return MAPI_E_CORRUPT_DATA;
}
//read the name of the property, eg Keywords
$hresult = $this->readBuffer($buffer, $len, $namedProp);
if ($hresult !== NOERROR) {
ZLog::Write(LOGLEVEL_WARN, "TNEF: There was an error reading stream property buffer");
return $hresult;
}
$size -= $len;
//Re-align
$buffer = substr($buffer, $len & 3 ? 4 - ($len & 3) : 0);
$size -= $len & 3 ? 4 - ($len & 3) : 0;
} else {
$hresult = $this->readFromTnefStream($buffer, self::DWORD, $namedProp);
if ($hresult !== NOERROR) {
ZLog::Write(LOGLEVEL_WARN, "TNEF: There was an error reading mapi property's length");
return $hresult;
}
ZLog::Write(LOGLEVEL_DEBUG, "TNEF: named: 0x" . sprintf("%04x", $namedProp));
$size -= 4;
}
if ($this->store !== false) {
$named = mapi_getidsfromnames($this->store, array($namedProp), array(makeguid($readableGuid)));
$propTag = mapi_prop_tag(mapi_prop_type($propTag), mapi_prop_id($named[0]));
} else {
ZLog::Write(LOGLEVEL_WARN, "TNEF: Store not available. It is impossible to get named properties");
}
}
ZLog::Write(LOGLEVEL_DEBUG, "TNEF: mapi prop tag: 0x" . sprintf("%04x", mapi_prop_id($propTag)) . " " . sprintf("%04x", mapi_prop_type($propTag)));
if ($propTag & MV_FLAG) {
if ($size < 4) {
return MAPI_E_CORRUPT_DATA;
}
//read the number of properties
$hresult = $this->readFromTnefStream($buffer, self::DWORD, $count);
//.........这里部分代码省略.........
示例4: _readSingleMapiProp
function _readSingleMapiProp(&$buffer, &$size, &$read, &$mapiprops)
{
$propTag = 0;
$len = 0;
$origSize = $size;
$isNamedId = 0;
$namedProp = 0;
$count = 0;
$mvProp = 0;
$guid = 0;
if ($size < 8) {
return MAPI_E_NOT_FOUND;
}
$hresult = $this->_readFromTnefStream($buffer, ZP_DWORD, $propTag);
if ($hresult !== NOERROR) {
debugLog("There was an error reading a mapi property tag from the stream.");
return $hresult;
}
$size -= 4;
//debugLog("mapi prop type:".dechex(mapi_prop_type($propTag)));
//debugLog("mapi prop tag: 0x".sprintf("%04x", mapi_prop_id($propTag)));
if (mapi_prop_id($propTag) >= 0x8000) {
// Named property, first read GUID, then name/id
if ($size < 24) {
debugLog("Corrupt guid size for named property:" . dechex($propTag));
return MAPI_E_CORRUPT_DATA;
}
//strip GUID & name/id
$hresult = $this->_readBuffer($buffer, 16, $guid);
if ($hresult !== NOERROR) {
debugLog("There was an error reading stream property buffer");
return $hresult;
}
$size -= 16;
//it is not used and is here only for eventual debugging
$readableGuid = unpack("VV/v2v/n4n", $guid);
$readableGuid = sprintf("{%08x-%04x-%04x-%04x-%04x%04x%04x}", $readableGuid['V'], $readableGuid['v1'], $readableGuid['v2'], $readableGuid['n1'], $readableGuid['n2'], $readableGuid['n3'], $readableGuid['n4']);
//debugLog("guid:$readableGuid");
$hresult = $this->_readFromTnefStream($buffer, ZP_DWORD, $isNamedId);
if ($hresult !== NOERROR) {
debugLog("There was an error reading stream property checksum.");
return $hresult;
}
$size -= 4;
if ($isNamedId != 0) {
// A string name follows
//read length of the property
$hresult = $this->_readFromTnefStream($buffer, ZP_DWORD, $len);
if ($hresult !== NOERROR) {
debugLog("There was an error reading mapi property's length");
return $hresult;
}
$size -= 4;
if ($size < $len) {
return MAPI_E_CORRUPT_DATA;
}
//read the name of the property, eg Keywords
$hresult = $this->_readBuffer($buffer, $len, $namedProp);
if ($hresult !== NOERROR) {
debugLog("There was an error reading stream property buffer");
return $hresult;
}
$size -= $len;
//Re-align
$buffer = substr($buffer, $len & 3 ? 4 - ($len & 3) : 0);
$size -= $len & 3 ? 4 - ($len & 3) : 0;
} else {
$hresult = $this->_readFromTnefStream($buffer, ZP_DWORD, $namedProp);
if ($hresult !== NOERROR) {
debugLog("There was an error reading mapi property's length");
return $hresult;
}
//debugLog("named: 0x".sprintf("%04x", $namedProp));
$size -= 4;
}
if ($this->_store !== false) {
$named = mapi_getidsfromnames($this->_store, array($namedProp), array(makeguid($readableGuid)));
$propTag = mapi_prop_tag(mapi_prop_type($propTag), mapi_prop_id($named[0]));
} else {
debugLog("Store not available. It is impossible to get named properties");
}
}
//debugLog("mapi prop tag: 0x".sprintf("%04x", mapi_prop_id($propTag))." ".sprintf("%04x", mapi_prop_type($propTag)));
if ($propTag & MV_FLAG) {
if ($size < 4) {
return MAPI_E_CORRUPT_DATA;
}
//read the number of properties
$hresult = $this->_readFromTnefStream($buffer, ZP_DWORD, $count);
if ($hresult !== NOERROR) {
debugLog("There was an error reading number of properties for:" . dechex($propTag));
return $hresult;
}
$size -= 4;
} else {
$count = 1;
}
for ($mvProp = 0; $mvProp < $count; $mvProp++) {
switch (mapi_prop_type($propTag) & ~MV_FLAG) {
case PT_I2:
//.........这里部分代码省略.........
示例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: propIsError
/**
* Check wether a call to mapi_getprops returned errors for some properties.
* mapi_getprops function tries to get values of properties requested but somehow if
* if a property value can not be fetched then it changes type of property tag as PT_ERROR
* and returns error for that particular property, probable errors
* that can be returned as value can be MAPI_E_NOT_FOUND, MAPI_E_NOT_ENOUGH_MEMORY
*
* @param long $property Property to check for error
* @param Array $propArray An array of properties
* @return mixed Gives back false when there is no error, if there is, gives the error
*/
function propIsError($property, $propArray)
{
if (array_key_exists(mapi_prop_tag(PT_ERROR, mapi_prop_id($property)), $propArray)) {
return $propArray[mapi_prop_tag(PT_ERROR, mapi_prop_id($property))];
} else {
return false;
}
}
示例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: 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;
}
示例9: 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;
}
示例10: getPropIdsFromStrings
function getPropIdsFromStrings($store, $mapping)
{
$props = array();
$ids = array("name" => array(), "id" => array(), "guid" => array(), "type" => array());
// this array stores all the information needed to retrieve a named property
$num = 0;
// caching
$guids = array();
foreach ($mapping as $name => $val) {
if (is_string($val)) {
$split = explode(":", $val);
if (count($split) != 3) {
// invalid string, ignore
trigger_error(sprintf("Invalid property: %s \"%s\"", $name, $val), E_USER_NOTICE);
continue;
}
if (substr($split[2], 0, 2) == "0x") {
$id = hexdec(substr($split[2], 2));
} else {
$id = $split[2];
}
// have we used this guid before?
if (!defined($split[1])) {
if (!array_key_exists($split[1], $guids)) {
$guids[$split[1]] = makeguid($split[1]);
}
$guid = $guids[$split[1]];
} else {
$guid = constant($split[1]);
}
// temp store info about named prop, so we have to call mapi_getidsfromnames just one time
$ids["name"][$num] = $name;
$ids["id"][$num] = $id;
$ids["guid"][$num] = $guid;
$ids["type"][$num] = $split[0];
$num++;
} else {
// not a named property
$props[$name] = $val;
}
}
if (count($ids["id"]) == 0) {
return $props;
}
// get the ids
$named = mapi_getidsfromnames($store, $ids["id"], $ids["guid"]);
foreach ($named as $num => $prop) {
$props[$ids["name"][$num]] = mapi_prop_tag(constant($ids["type"][$num]), mapi_prop_id($prop));
}
return $props;
}