[EWS]查找 文件夹
Posted tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[EWS]查找 文件夹相关的知识,希望对你有一定的参考价值。
摘要
有时在操作exchange的时候,需要查找用户exchange文件夹,比如用户新建了一些文件夹。
一个例子
这里以查找用户outlook邮箱中的历史对话文件夹为例。
private const ExchangeVersion EXCHANGE_VERSION = ExchangeVersion.Exchange2010_SP2; private ExchangeService _service; public MyExchangeClient(UserInfo userInfo) { if (userInfo == null) { throw new ArgumentNullException("user is empty"); } this._userInfo = userInfo; this._service = new ExchangeService(EXCHANGE_VERSION); _service.Credentials = new NetworkCredential(userInfo.Itcode, userInfo.Pwd, _userInfo.Domain); _service.Url = new Uri(ConfigManager.ExchangeServerUrl); }
/// <summary> /// 查找对话历史文件夹 /// </summary> /// <returns></returns> private Folder FindImHistoryFolder() { int _pageSize = 10; FolderView folderView = new FolderView(_pageSize, 0); folderView.PropertySet = new PropertySet(BasePropertySet.IdOnly); folderView.PropertySet.Add(FolderSchema.DisplayName); folderView.PropertySet.Add(FolderSchema.ChildFolderCount); folderView.Traversal = FolderTraversal.Shallow; Folder imHistoryFolder = null; FindFoldersResults findFolderResults; bool foundImHistoryFolder = false; do { findFolderResults = this._service.FindFolders(WellKnownFolderName.MsgFolderRoot, folderView); foreach (Folder folder in findFolderResults) { if (folder.DisplayName.ToLower() == "conversation history" || folder.DisplayName.ToLower() == "对话历史记录") { imHistoryFolder = folder; foundImHistoryFolder = true; } } folderView.Offset += _pageSize; } while (findFolderResults.MoreAvailable && !foundImHistoryFolder); return imHistoryFolder; }
以上是关于[EWS]查找 文件夹的主要内容,如果未能解决你的问题,请参考以下文章
需要一种使用 EWS Web 服务 (SOAP) 查找 Exchange 产品版本的方法