从 EWS 访问 Outlook 用户属性 [英] Access Outlook user properties from EWS
问题描述
我正在尝试创建一个使用 EWS api 访问联系人的应用程序.
I'm trying to create an application that use the EWS api to access contacts.
在此过程中,我需要查看 Outlook 用户属性之一,但在使用 EWS 时我看不到如何获得它.目前我刚刚尝试...
I need to look at one of the outlook user properties in this process but I cant see how to get it at using EWS. At the moment ive just tried...
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.
Which compiles and executes without a problem, but for every contact the ExtendedProperties count is 0 which in outlook its about 30.
那么我怎样才能获得我正在寻找的属性?
So how can I get the properties I'm looking for?
仅供参考.我使用的是exhcnage 2007.
Just an FYI. Im using exhcnage 2007.
谢谢.
推荐答案
您需要定义想要获取的属性 - EWS 不允许您枚举用户属性.
You need to define the properties you want to get - EWS does not permit you to enumerate user properties.
用户属性位于命名空间 PublicStrings 中.
The Userproperties are in the namespace PublicStrings.
private static readonly ExtendedPropertyDefinition CustomProperty = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.PublicStrings, "MyCustomProperty", MapiPropertyType.String);
然后您可以在 FindItems 请求中使用该定义:
You can then use the definition in a FindItems request:
var items = service.FindItems(WellKnownFolderName.Inbox, new ItemView(100) { PropertySet = new PropertySet(BasePropertySet.FirstClassProperties, CustomProperty)});
这篇关于从 EWS 访问 Outlook 用户属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!