Exchange Web服务使用PHP-EWS获取公共子文件夹

时间:2016-06-14 08:31:38

标签: php exchange-server exchangewebservices php-ews

我在cakePHP应用程序中使用PHP-EWS(https://github.com/jamesiarmes/php-ews)。目标是从公共文件夹"中读取电子邮件。来自交换服务器。

问题是我只能阅读第一个" Dimension"公用文件夹,无法找到获取子目录的方法。

我必须阅读的文件夹有4个级别。

 $this->connect();

// start building the find folder request 
$request = new FindFolderType();
$request->Traversal = FolderQueryTraversalType::SHALLOW;
$request->FolderShape = new FolderResponseShapeType();
$request->FolderShape->BaseShape = DefaultShapeNamesType::ALL_PROPERTIES;

// configure the view
$request->IndexedPageFolderView = new IndexedPageViewType();
$request->IndexedPageFolderView->BasePoint = 'Beginning';
$request->IndexedPageFolderView->Offset = 0;

// set the starting folder
$request->ParentFolderIds = new NonEmptyArrayOfBaseFolderIdsType();
$request->ParentFolderIds->DistinguishedFolderId = new    DistinguishedFolderIdType();
$request->ParentFolderIds->DistinguishedFolderId->Id = DistinguishedFolderIdNameType::PUBLIC_FOLDERS_ROOT;

// request 
$response = $this->ews->FindFolder($request);

如果我改变" Traversal"为了DEEP我得到了错误。

  

公共文件夹不允许使用DEEP TRAVERSAL查询。

我也试图改变

$request->IndexedPageFolderView->BasePoint

像" end" "秒",它没有改变任何东西,所以我无法弄清楚它做了什么以及如何使用它。

我无法获取子目录文件夹ID(用于更改起点),因为它从未被选中。

感谢您的帮助。

1 个答案:

答案 0 :(得分:1)

非常好的问题。不幸的是,您选择的图书馆已过时且未经过维护。我个人建议你使用我最新的garethp/php-ews

我不知道这是否是最好的解决方案,但我建议的是获得第一级文件夹,然后是第二级文件夹,依此类推。因此,如果您知道文件夹的目录结构,它看起来像这样

- Folder 1
    - Subfolder 1
        - Subfolder 2
            - Subfolder 3 (Target)
- Folder 2
- Folder 3

然后首先你得到文件夹1,它将是DistinguishedFolderIdNameType::PUBLIC_FOLDERS_ROOT的孩子。然后,您将获得Subfolder 1的{​​{1}}孩子,然后获得Folder 1,然后获得Subfolder 2。我无法告诉您如何使用您当前正在使用的图书馆来管理图书馆,但我的图书馆看起来就像

Subfolder 3

显然有很多电话,所以如果您经常使用该文件夹ID,我会将FolderID保存到数据库中以便以后更快地检索

相关问题