[EWS]查找 文件夹

前端之家收集整理的这篇文章主要介绍了[EWS]查找 文件夹前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

摘要

有时在操作exchange的时候,需要查找用户exchange文件夹,比如用户新建了一些文件夹。

一个例子

这里以查找用户outlook邮箱中的历史对话文件夹为例。

ExchangeVersion EXCHANGE_VERSION = </span><span style="color: #0000ff;"&gt;public</span><span style="color: #000000;"&gt; MyExchangeClient(UserInfo userInfo) { </span><span style="color: #0000ff;"&gt;if</span> (userInfo == <span style="color: #0000ff;"&gt;null</span><span style="color: #000000;"&gt;) { </span><span style="color: #0000ff;"&gt;throw</span> <span style="color: #0000ff;"&gt;new</span> ArgumentNullException(<span style="color: #800000;"&gt;"</span><span style="color: #800000;"&gt;user is empty</span><span style="color: #800000;"&gt;"</span><span style="color: #000000;"&gt;); } </span><span style="color: #0000ff;"&gt;this</span>._userInfo =<span style="color: #000000;"&gt; userInfo; </span><span style="color: #0000ff;"&gt;this</span>._service = <span style="color: #0000ff;"&gt;new</span><span style="color: #000000;"&gt; ExchangeService(EXCHANGE_VERSION);

_service.Credentials = <span style="color: #0000ff;">new<span style="color: #000000;"> NetworkCredential(userInfo.Itcode,userInfo.Pwd,_userInfo.Domain);
_service.Url = <span style="color: #0000ff;">new<span style="color: #000000;"> Uri(ConfigManager.ExchangeServerUrl);

    }</span></pre>
文件夹 _pageSize = = FolderView(_pageSize,= folderView.Traversal </span>=<span style="color: #000000;"&gt; FolderTraversal.Shallow; Folder imHistoryFolder </span>= <span style="color: #0000ff;"&gt;null</span><span style="color: #000000;"&gt;; FindFoldersResults findFolderResults; </span><span style="color: #0000ff;"&gt;bool</span> foundImHistoryFolder = <span style="color: #0000ff;"&gt;false</span><span style="color: #000000;"&gt;; </span><span style="color: #0000ff;"&gt;do</span><span style="color: #000000;"&gt; { findFolderResults </span>= <span style="color: #0000ff;"&gt;this</span><span style="color: #000000;"&gt;._service.FindFolders(WellKnownFolderName.MsgFolderRoot,folderView); </span><span style="color: #0000ff;"&gt;foreach</span> (Folder folder <span style="color: #0000ff;"&gt;in</span><span style="color: #000000;"&gt; findFolderResults) { </span><span style="color: #0000ff;"&gt;if</span> (folder.DisplayName.ToLower() == <span style="color: #800000;"&gt;"</span><span style="color: #800000;"&gt;conversation history</span><span style="color: #800000;"&gt;"</span> || folder.DisplayName.ToLower() == <span style="color: #800000;"&gt;"</span><span style="color: #800000;"&gt;对话历史记录</span><span style="color: #800000;"&gt;"</span><span style="color: #000000;"&gt;) { imHistoryFolder </span>=<span style="color: #000000;"&gt; folder; foundImHistoryFolder </span>= <span style="color: #0000ff;"&gt;true</span><span style="color: #000000;"&gt;; } } folderView.Offset </span>+=<span style="color: #000000;"&gt; _pageSize; } </span><span style="color: #0000ff;"&gt;while</span> (findFolderResults.MoreAvailable &amp;&amp; !<span style="color: #000000;"&gt;foundImHistoryFolder); </span><span style="color: #0000ff;"&gt;return</span><span style="color: #000000;"&gt; imHistoryFolder; }</span></pre>

 

原文链接:https://www.f2er.com/csharp/191505.html

猜你在找的C#相关文章