从ExchangeUser对象获取国家/地区信息

时间:2012-08-22 11:03:58

标签: c# outlook vsto exchange-server outlook-addin

我正在编写一个Outlook Interop应用程序,我需要从Exchange用户对象获取country / region条目。它不能通过公共财产获得,有什么方法可以获得它吗?

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;
}

1 个答案:

答案 0 :(得分:1)

您可以使用ExchangeUser.PropertyAccessor来检索国家/地区属性。如果该属性不存在,您需要try / catch。请参阅source referenceMail User Properties

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