通过PHP从Exchange Web服务获取未读邮件
作者:互联网
在使用this class时,如何使用PHP如何在用户的交换邮箱中获取所有未读邮件?
我想首先列出这样的文件夹内容:
$ews = new ExchangeWebServices("mailserver.domain.local", "user", "pass");
$request = new EWSType_FindFolderType();
$request->FolderShape = new EWSType_FolderResponseShapeType();
$request->FolderShape->BaseShape = EWSType_DefaultShapeNamesType::DEFAULT_PROPERTIES;
$request->ParentFolderIds = new EWSType_NonEmptyArrayOfBaseFolderIdsType();
$request->ParentFolderIds->DistinguishedFolderId = new EWSType_DistinguishedFolderIdType();
$request->ParentFolderIds->DistinguishedFolderId->Id = EWSType_DistinguishedFolderIdNameType::INBOX;
$request->Traversal = new EWSType_FolderQueryTraversalType();
$result = $ews->FindFolder($request);
var_dump($result);
只有这样我才得到这个错误:
可捕获的致命错误:无法将类EWSType_FolderQueryTraversalType的对象转换为字符串
有没有在这堂课上有经验的人可以告诉我我做错了什么?
我确实知道必须传递一个字符串,但是似乎该类只有3个常量,没有任何函数或其他属性.
解决方法:
我想通了,在上面的例子中我不得不使用
$request->Traversal = EWSType_FolderQueryTraversalType::DEEP;
由于它只有3个常数.
但是将其张贴在这里,因为我认为这可能对其他希望这样做的人有用,将您收件箱中的所有邮件列出如下:
$ews = new ExchangeWebServices("mailserver.domain.local", "user", "pass");
$request = new EWSType_FindItemType();
$request->ItemShape = new EWSType_ItemResponseShapeType();
$request->ItemShape->BaseShape = EWSType_DefaultShapeNamesType::DEFAULT_PROPERTIES;
$request->ParentFolderIds = new EWSType_NonEmptyArrayOfBaseFolderIdsType();
$request->ParentFolderIds->DistinguishedFolderId = new EWSType_DistinguishedFolderIdType();
$request->ParentFolderIds->DistinguishedFolderId->Id = EWSType_DistinguishedFolderIdNameType::INBOX;
$request->Traversal = EWSType_ItemQueryTraversalType::SHALLOW;
$result = $ews->FindItem($request);
标签:exchangewebservices,php-ews,php,soap 来源: https://codeday.me/bug/20191102/1990973.html