我正在编写Outlook Interop应用程序,需要从交换用户对象获取国家(地区)条目。它不能通过公共财产获得,反正有什么办法吗?

ExchangeUser entry = OutlookManager.Instance.GetAddressBookEntry(mail.SenderName, mail.SenderAddress);

if (entry != null)
{
    var licensee = new Licensee();
    licensee.City = entry.City;
    licensee.Company = entry.CompanyName;
    //todo get country
    licensee.Country = ???
    licensee.Department = entry.Department;
    licensee.FirstName = entry.FirstName;
    licensee.LastName = entry.LastName;
    licensee.OutlookDisplayName = entry.Name;
}

最佳答案

您可以使用ExchangeUser.PropertyAccessor来检索Country属性。如果该属性不存在,则需要尝试/捕获。请参见source reference和可用的Mail User Properties

try {
    licensee.Country = entry.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x3A26001E");
}
catch { licensee.Country = ""; }

08-18 21:38