Exchange Web服务FolderId为一个不太知名的文件夹名称 [英] Exchange Web Service FolderId for a not well known folder name

查看:222
本文介绍了Exchange Web服务FolderId为一个不太知名的文件夹名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Exchange邮箱中有一个文件夹,该文件夹是根目录的子目录(不是收件箱").

I have a folder in an Exchange mailbox that is a child of the root (not Inbox).

如何使用EWS托管API获取此类文件夹的ID?

How do I get the ID of such folder using EWS Managed API?

我发现的唯一示例是与WellKnownFolderNames有关的示例.

Only examples I find are those relating to WellKnownFolderNames.

推荐答案

您可以使用FindFolders方法找到所有文件夹.使用WellKnownFolderName.Root显示收件箱中的所有文件夹.您必须创建一个FolderView并添加要查看的属性(例如,IDDisplayName).将遍历设置为Deep以查找所有文件夹.在我的示例中,我正在寻找带有DisplayName测试"的文件夹.

You can find all Folders with the FindFolders method. Use WellKnownFolderName.Root to show all your folders of your Inbox. You have to create a FolderView and add the properties you want to see (ID and DisplayName for example). Set the traversal to Deep to find all of your folders. In my example, I'm looking for the folder with the DisplayName "Test".

// set Server
ExchangeService server = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
server.UseDefaultCredentials = true;
string configUrl = @"https://yourServerAddress.asmx";
server.Url = new Uri(configUrl);

// set View
FolderView view = new FolderView(100);
view.PropertySet = new PropertySet(BasePropertySet.IdOnly);
view.PropertySet.Add(FolderSchema.DisplayName);
view.Traversal = FolderTraversal.Deep;

FindFoldersResults findFolderResults = server.FindFolders(WellKnownFolderName.Root, view);

// find specific folder
foreach (Folder f in findFolderResults)
{
    // show FolderId of the folder "Test"
    if (f.DisplayName == "Test")
    {
        Console.WriteLine(f.Id);
    }
}

这篇关于Exchange Web服务FolderId为一个不太知名的文件夹名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆