我目前正在尝试通过Microsoft的EWS托管API从Outlook联系人对象中读取特定属性。 我通过FindItems()
函数检索这些联系人对象。其中一些字段是扩展属性,例如Title
或User1
字段,我无法读取它们。目前,我有:
Guid propertySetId = new Guid("{00062004-0000-0000-C000-000000000046}");
ExtendedPropertyDefinition titleProp = new ExtendedPropertyDefinition(propertySetId, 0x3A45, MapiPropertyType.String);
ExtendedPropertyDefinition user1Prop = new ExtendedPropertyDefinition(propertySetId, 0x804F, MapiPropertyType.String);
string title, user1;
contact.TryGetProperty(titleProp, out title);
contact.TryGetProperty(user1Prop, out user1);
运行此代码时,
TryGetProperty
始终返回 false。我已验证这些字段在我要搜索的 Outlook 联系人中是填充的。编辑:这是我检索联系人对象的方式。
ExchangeService service = //...
Mailbox userMailbox = new Mailbox(emailAddress);
FolderId folderId = new FolderId(WellKnownFolderName.Contacts, userMailbox);
FindItemsResults<Item> results;
const string AQS = "Category:~>\"CategoryTag\"";
ItemView view = new ItemView(200);
results = service.FindItems(folderId, AQS, view);
foreach (var result in results)
{
Contact contact = result as Contact;
//...Try to read fields
}
Contact.Bind()
的代码或者其他获取contact
字段引用的方式。 - SliverNinja - MSFT