从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,这在其展望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.
Userproperties是在命名空间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屋!