我需要一项Cron作业才能仅获取自上次同步以来在Exchange服务器中收到的新电子邮件。
我使用imap服务器进行了相同的编码,并且很容易获得具有ID的电子邮件。因此,我将for循环结束时的最后一个ID保存到数据库,并在下次cron作业执行时从该ID恢复。
我在Exchange中尝试过相同的操作,但出现以下错误: 未能搜索带有“ ErrorInvalidValueForProperty:特殊性”的消息。
要在Exchange中获取ItemId,我正在使用以下代码,没有错误:
$item->ItemId->Id;
它返回类似:
AAMkADk3ZWRhY2VmLTdiY2UtNDkxYy04ZDMyLWZiZWIyYTQ4ZjQyMABGAAAAAAChH5wDkXAqTZaoH1oRodz8BwD8BvGliMkPTK/cnnmZJDPUAAAAvGXfAAD8BvGliMkPTK/cnnmZJDPUAAAAvJN5AAA=
要查找电子邮件,我正在尝试以下代码(具有前面提到的错误):
$request = new FindItemType();
$request->ParentFolderIds = new NonEmptyArrayOfBaseFolderIdsType();
$request->Traversal = ItemQueryTraversalType::SHALLOW;
$greater_than = new IsGreaterThanOrEqualToType();
$greater_than->FieldURI = new PathToUnindexedFieldType();
$greater_than->FieldURI->FieldURI = UnindexedFieldURIType::ITEM_ID;
$greater_than->FieldURIOrConstant = new FieldURIOrConstantType();
$greater_than->FieldURIOrConstant->Constant = new ConstantValueType();
$greater_than->FieldURIOrConstant->Constant->Value = $UID;
谢谢!
答案 0 :(得分:0)
EWS ItemId不是可搜索的属性,因为它不必是例如,您可以将Bind绑定到相关ID以查看该Item是否存在。如果它不再存在,那么您将得到一个特定的错误来告诉您。 SyncFolderItems操作可能是更适合使用的方法,但是https://docs.microsoft.com/en-us/exchange/client-developer/web-service-reference/syncfolderitems-operation。