我使用jamesiarmes / php-ews连接Exchange服务器以获取电子邮件列表。
$ews = new ExchangeWebServices('[host]', '[username]', '[password]');
$request = new EWSType_FindItemType();
$request->ItemShape = new EWSType_ItemResponseShapeType();
$request->ItemShape->BaseShape = EWSType_DefaultShapeNamesType::DEFAULT_PROPERTIES;
$request->Traversal = EWSType_ItemQueryTraversalType::SHALLOW;
$request->ParentFolderIds = new EWSType_NonEmptyArrayOfBaseFolderIdsType();
$request->ParentFolderIds->DistinguishedFolderId = new EWSType_DistinguishedFolderIdType();
$request->ParentFolderIds->DistinguishedFolderId->Id = EWSType_DistinguishedFolderIdNameType::SENT_ITEMS;
// sort order
$request->SortOrder = new EWSType_NonEmptyArrayOfFieldOrdersType();
$request->SortOrder->FieldOrder = array();
$order = new EWSType_FieldOrderType();
// sorts mails so that oldest appear first
// more field uri definitions can be found from types.xsd (look for UnindexedFieldURIType)
$order->FieldURI->FieldURI = 'item:DateTimeReceived';
$order->Order = 'Ascending';
$request->SortOrder->FieldOrder[] = $order;
$response = $ews->FindItem($request);
echo '<pre>'.print_r($response, true).'</pre>';
我想收到发送的项目:
EWSType_DistinguishedFolderIdNameType::SENT_ITEMS;
此脚本打印
[0] => stdClass Object
(
[ItemId] => stdClass Object
(
[Id] => AQAeAGptYXJzY2hhbGwAQGdyb3VwLm1va2F0ZS5jb20ucGwARgAAA9S15wLis8lApRvdnAdC+XoHAC51TyudPmVDoXWXKV00MAYAAAIBCgAAAC51TyudPmVDoXWXKV00MAYAAAIedwAAAA==
[ChangeKey] => CQAAABYAAAAudU8rnT5lQ6F1lyldNDAGAAAAAB6h
)
[Subject] => test
[Sensitivity] => Normal
[Size] => 3534
[DateTimeSent] => 2014-07-03T06:56:17Z
[DateTimeCreated] => 2014-07-03T06:56:17Z
[HasAttachments] =>
[From] => stdClass Object
(
[Mailbox] => stdClass Object
(
[Name] => [name]
[EmailAddress] => /O=GROUP TEST/OU=EXCHANGE ADMINISTRATIVE GROUP (FYDIBOHF23SPDLT)/CN=RECIPIENTS/CN=59219DC26E6D463AB22C558CC646227D-name
[RoutingType] => EX
)
)
[IsRead] => 1
)
所以,我的问题是我如何获得收件人的电子邮件地址?有可能吗?
非常感谢你的帮助。
答案 0 :(得分:0)
当您使用FindItem请求时,您需要在要获取收件人的特定ItemId上发出GetItem请求http://msdn.microsoft.com/en-us/library/office/aa565934(v=exchg.150).aspx时,不会返回消息的收件人(以及许多其他属性)对于。如果您需要为大量项目执行此操作,您可以批量生成GetItems请求,例如http://blogs.msdn.com/b/exchangedev/archive/2010/03/16/loading-properties-for-multiple-items-with-one-call-to-exchange-web-services.aspx
干杯 格伦