我目前正在尝试通过 Microsoft 的 EWS 托管 API 从 Outlook 联系人对象中读取某些属性。我从FindItems()
函数中检索这些联系人对象。其中一些字段是扩展属性,例如Title
orUser1
字段,我很难阅读它们。目前,我有:
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
}