本文介绍了如何从文件夹和PublicFolders的子文件夹中的所有项目使用EWS托管API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何从公共文件夹和子文件夹中的所有项目,以换取server2010 uisng管理API ???
How to retrieve all items from "public folders" and its "sub-folders" in exchange server2010 uisng managed API???
rootfolder = Folder.Bind(service,WellKnownFolderName.PublicFoldersRoot);
rootfolder.Load();
foreach (Folder folder in rootfolder.FindFolders(new FolderView(int.MaxValue)))
{
FindItemsResults<Item> findResults = folder.FindItems(iv);
foreach (Item item in findResults)
{
//get item info;
}
}
如果我不喜欢这it..public文件夹的子文件夹中我没有得到项目present不支持深度遍历查询too..How我可以得到公共文件夹的子文件夹的项目? ??
"If i do like this i am not getting items present in sub-folders of it..public folders does not support deep traversal queries too..How can i get items from sub-folders of public folders???"
推荐答案
要获得所有文件夹使用以下code:
To get all folders use the code below:
public void GetAllFolders(ExchangeService service, List<Folder> completeListOfFolderIds)
{
FolderView folderView = new FolderView(int.MaxValue);
FindFoldersResults findFolderResults = service.FindFolders(WellKnownFolderName.PublicFoldersRoot, folderView);
foreach (Folder folder in findFolderResults)
{
completeListOfFolderIds.Add(folder);
FindAllSubFolders(service, folder.Id, completeListOfFolderIds);
}
}
private void FindAllSubFolders(ExchangeService service, FolderId parentFolderId, List<Folder> completeListOfFolderIds)
{
//search for sub folders
FolderView folderView = new FolderView(int.MaxValue);
FindFoldersResults foundFolders = service.FindFolders(parentFolderId, folderView);
// Add the list to the growing complete list
completeListOfFolderIds.AddRange(foundFolders);
// Now recurse
foreach (Folder folder in foundFolders)
{
FindAllSubFolders(service, folder.Id, completeListOfFolderIds);
}
}
要获得所有项目:
List<Folder> completeListOfFolderIds = new List<Folder>();
//Fills list with all public folders and subfolders
GetAllFolders(service, completeListOfFolderIds);
foreach(Folder folder in completeListOfFolderIds)
{
ItemView itemView = new ItemView(int.MaxValue);
FindItemsResults<Item> searchResults = service.FindItems(folder.Id, itemView);
//do something with item list
}
这篇关于如何从文件夹和PublicFolders的子文件夹中的所有项目使用EWS托管API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!