Getting unread mail from exchange web services via PHP

余生颓废 提交于 2019-12-05 03:31:31

问题


How do you get all unread mail in a users' exchange mailbox using PHP while using this class ?

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?

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..


回答1:


I figured it out, in above example I had to use

$request->Traversal = EWSType_FolderQueryTraversalType::DEEP;

Since it only had the 3 constants.

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);


来源:https://stackoverflow.com/questions/6813589/getting-unread-mail-from-exchange-web-services-via-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!