【问题标题】:Get Country/Region Information from ExchangeUser Object从 ExchangeUser 对象获取国家/地区信息
【发布时间】:2013-10-16 20:05:05
【问题描述】:

我正在编写一个 Outlook 互操作应用程序,我需要从一个交换用户对象中获取国家/地区条目。不能通过公共属性获得,有什么办法可以得到吗?

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

【问题讨论】:

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


    【解决方案1】:

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

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

    【讨论】:

    • 谢谢。有趣的是,如果我通过 Outlook 查看地址簿条目,虽然 Region/Country 字段存在,但会引发 COM 异常。
    • 国家/地区在 Outlook 中的地址簿条目下显示在哪里?有多个国家/地区字段。它可以是 PR_COUNTRY、PR_BUSINESS_ADDRESS_COUNTRY、PR_HOME_ADDRESS_COUNTRY 或 PR_OTHER_ADDRESS_COUNTRY。请参阅Mail User Properties 以确定要检索的属性标签 (proptag)。
    • 它显示在“常规”中,我已经尝试了所有这些属性,不幸的是没有一个有效。
    • 单击“显示”功能区选项卡下的“所有字段”时,它会显示在什么属性下?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多