获取作为交换用户的收件人的电子邮件地址

Nad*_*lah 9 vsto ms-office outlook-addin

在我的VSTO Outlook 2007插件中,我可以获取作为交换用户的收件人的电子邮件地址.但是,当我有以下情况时,它不会返回smtp电子邮件:

  1. 添加新的Outlook联系人项目(在Outlook联系人中).
  2. 此联系人项目的电子邮件地址应为交换用户的电子邮件(您组织的任何人,但这是交换用户).
  3. 现在,当我选择此Outlook联系人作为电子邮件收件人时,在项目发送事件中,我无法获取smtp地址.

以下是我的代码:

    Recipient r = mailItem.Recipients[i];
r.Resolve();
//Note, i have different conditions that check the AddressEntryUserType of recipient's 
//address entry object. All other cases work fine. In this case this is 
//olOutlookContactAddressEntry. 
//I have tried the following:

 ContactItem cont = r.AddressEntry.GetContact();
 string email = cont.Email1Address;
 string emailtmp = r.AddressEntry.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x800F101E") as string;
Run Code Online (Sandbox Code Playgroud)

任何人都可以请帮助我在这种情况下我应该使用什么属性来获取smtp电子邮件?

kav*_*vun 6

我找到了一种使用 ExchangeUser 项目并通过该对象解析 smtp 地址的方法。这篇文章有帮助 -从存储在 Exchange 中的 ContactInfo 获取 Smtp 电子邮件

    foreach (Outlook.Recipient recipient in currentAppointment.Recipients)
    {
        Outlook.ExchangeUser exchangeUser = recipient.AddressEntry.GetExchangeUser();
        string smtpAddress;
        if (exchangeUser != null)
        {
             smtpAddress = exchangeUser.PrimarySmtpAddress;
        }
        else
        {
             smtpAddress = recipient.Address;
        }
    }
Run Code Online (Sandbox Code Playgroud)


Dar*_*inH 0

如果我没记错的话,在某些情况下,除非您先保存要发送的项目,否则电子邮件地址将无法解析。你可以尝试一下。另外,您是否没有收到任何请求访问用户地址簿权限的“安全违规”消息,或者您是否禁用/解决了所有这些问题?我遇到了很多问题,最终需要使用 Outlook 的赎回。