c# - 从 EWS 访问 Outlook 用户属性

标签 c# outlook exchangewebservices exchange-server-2007

我正在尝试创建一个使用 EWS api 访问联系人的应用程序。

我需要查看此过程中的一个 Outlook 用户属性,但我看不到如何使用 EWS 获取它。目前我刚刚试过...

service.Url = new Uri("https://url/ews/Exchange.asmx");
service.Credentials = new WebCredentials("credentials");
var results = service.FindItems(folderId, new ItemView(100));
foreach (var item in results)
{
     Contact contact = item as Contact;
     foreach (var prop in contact.ExtendedProperties)
     {
            Console.WriteLine(prop.Value.ToString());
     }
}

编译和执行没有问题,但对于每个联系人,ExtendedProperties 计数为 0,在 outlook 中大约为 30。

那么我怎样才能得到我正在寻找的属性呢?

仅供引用。我使用的是 exhcnage 2007。

谢谢。

最佳答案

您需要定义要获取的属性 - EWS 不允许您枚举用户属性。

Userproperties 在命名空间 PublicStrings 中。

private static readonly ExtendedPropertyDefinition CustomProperty = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.PublicStrings, "MyCustomProperty", MapiPropertyType.String);

然后您可以在 FindItems 请求中使用该定义:

var items = service.FindItems(WellKnownFolderName.Inbox, new ItemView(100) { PropertySet =   new PropertySet(BasePropertySet.FirstClassProperties, CustomProperty)});

关于c# - 从 EWS 访问 Outlook 用户属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6745452/

相关文章:

c# - ComboBox.SelectedIndexChanging?

excel - 添加超链接(Web)到 Outlook 电子邮件

vba - 错误 440 "Array Index out of Bounds"

python - 在VBA Outlook中运行Python或PowerShell

c# - EWS : Accessing an appointments recurrence pattern

c# - Microsoft Exchange Folders.findItems 结果限制为 1000

c# - 目录搜索器可以查询操作属性吗?

c# - 将数据库上下文提供给对象工厂

c# - 如何更新 Exchange Web Api 中的联系人项目

c# - 扩展方法是如何工作的?