通过PHP从Exchange Web服务获取未读邮件 [英] Getting unread mail from exchange web services via PHP
问题描述
如何在使用此类时使用PHP在用户的交换邮箱中获取所有未读邮件吗?
我想首先列出一个像这样的文件夹内容:
I figured to first list a folders contents like this:
$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);
只有这样我会收到此错误:
Only then I get this error:
Catchable fatal error: Object of class EWSType_FolderQueryTraversalType could not be converted to string
有没有在这堂课上有经验的人可以告诉我我做错了什么?
Is there anybody with experience with this class that can tell me what I'm doing wrong?
我确实知道必须传递一个字符串,但是似乎该类只有3个常量,没有任何函数或其他属性.
I do know that a string has to be passed, but it seems the class has just 3 constants without any functions or other properties..
推荐答案
我知道了,在上面的示例中我不得不使用
I figured it out, in above example I had to use
$request->Traversal = EWSType_FolderQueryTraversalType::DEEP;
因为它只有3个常数.
但是将其张贴在这里,因为我认为这可能对其他希望这样做的人有用,因此列出收件箱中的所有邮件如下:
But posting it here since I think it might be useful for anyone else looking to do the same, listing all mail in your inbox goes as follows:
$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);
这篇关于通过PHP从Exchange Web服务获取未读邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!