摘要
有时在操作exchange的时候,需要查找用户exchange文件夹,比如用户新建了一些文件夹。
一个例子
ExchangeVersion EXCHANGE_VERSION =
_service.Url = <span style="color: #0000ff;">new<span style="color: #000000;"> Uri(ConfigManager.ExchangeServerUrl);
</span><span style="color: #0000ff;">public</span><span style="color: #000000;"> MyExchangeClient(UserInfo userInfo)
{
</span><span style="color: #0000ff;">if</span> (userInfo == <span style="color: #0000ff;">null</span><span style="color: #000000;">)
{
</span><span style="color: #0000ff;">throw</span> <span style="color: #0000ff;">new</span> ArgumentNullException(<span style="color: #800000;">"</span><span style="color: #800000;">user is empty</span><span style="color: #800000;">"</span><span style="color: #000000;">);
}
</span><span style="color: #0000ff;">this</span>._userInfo =<span style="color: #000000;"> userInfo;
</span><span style="color: #0000ff;">this</span>._service = <span style="color: #0000ff;">new</span><span style="color: #000000;"> 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;"> FolderTraversal.Shallow;
Folder imHistoryFolder </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">;
FindFoldersResults findFolderResults;
</span><span style="color: #0000ff;">bool</span> foundImHistoryFolder = <span style="color: #0000ff;">false</span><span style="color: #000000;">;
</span><span style="color: #0000ff;">do</span><span style="color: #000000;">
{
findFolderResults </span>= <span style="color: #0000ff;">this</span><span style="color: #000000;">._service.FindFolders(WellKnownFolderName.MsgFolderRoot,folderView);
</span><span style="color: #0000ff;">foreach</span> (Folder folder <span style="color: #0000ff;">in</span><span style="color: #000000;"> findFolderResults)
{
</span><span style="color: #0000ff;">if</span> (folder.DisplayName.ToLower() == <span style="color: #800000;">"</span><span style="color: #800000;">conversation history</span><span style="color: #800000;">"</span> || folder.DisplayName.ToLower() == <span style="color: #800000;">"</span><span style="color: #800000;">对话历史记录</span><span style="color: #800000;">"</span><span style="color: #000000;">)
{
imHistoryFolder </span>=<span style="color: #000000;"> folder;
foundImHistoryFolder </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">;
}
}
folderView.Offset </span>+=<span style="color: #000000;"> _pageSize;
} </span><span style="color: #0000ff;">while</span> (findFolderResults.MoreAvailable && !<span style="color: #000000;">foundImHistoryFolder);
</span><span style="color: #0000ff;">return</span><span style="color: #000000;"> imHistoryFolder;
}</span></pre>
原文链接:https://www.f2er.com/csharp/191505.html