我正在尝试使用PHP EWS在交换服务器上检索特定发件人的电子邮件列表。
我的代码示例专门与限制(搜索)构造相关:
$request->Restriction = new EWSType_RestrictionType();
$request->Restriction->IsEqualTo = new EWSType_IsEqualToType();
$request->Restriction->IsEqualTo->FieldURI = new EWSType_PathToUnindexedFieldType();
$request->Restriction->IsEqualTo->FieldURI->FieldURI = 'message:Sender';
$request->Restriction->IsEqualTo->FieldURIOrConstant = new EWSType_FieldURIOrConstantType();
$request->Restriction->IsEqualTo->FieldURIOrConstant->Constant->Value = 'Bob Smith';
此类限制导致零结果。
我注意到当我搜索没有限制时,返回的结果包含发件人信息(但它是嵌套的)。例如:
[Sender] => stdClass Object
(
[Mailbox] => stdClass Object
(
[Name] => Bob Smith
)
)
我如何满足限制中的嵌套信息?
其他搜索表达示例:https://github.com/jamesiarmes/php-ews/wiki/Search-Expression:-Simple-Conditions
答案 0 :(得分:4)
基于MSDN文档,消息:Sender具有以下定义:
物业价值
键入:Microsoft.Exchange.WebServices.Data.EmailAddress
电子邮件地址。
因此,使用电子邮件地址('bsmith@foo.com'),而不是使用限定名称“Bob Smith”(Outlook可能会识别它,但EWS没有线索)。
此外,虽然上面的代码应该工作,但它可能会抛出一个错误,因为Constant永远不会被定义。试试这个:
$request->Restriction->IsEqualTo->FieldURIOrConstant = new EWSType_FieldURIOrConstantType();
$request->Restriction->IsEqualTo->FieldURIOrConstant->Constant = new EWSType_ConstantValueType();
$request->Restriction->IsEqualTo->FieldURIOrConstant->Constant->Value = 'bsmith@foo.com';