3

在使用此类时,如何使用 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);

只有这样我才得到这个错误:

Catchable fatal error: Object of class EWSType_FolderQueryTraversalType could not be converted to string

有没有人有这门课的经验可以告诉我我做错了什么?

我知道必须传递一个字符串,但该类似乎只有 3 个常量,没有任何函数或其他属性。

4

1 回答 1

4

我想通了,在上面的例子中我不得不使用

$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);
于 2011-07-25T09:35:12.210 回答