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

标签 ms-office vsto outlook-addin

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

  • 添加新的 Outlook 联系人项目(在 Outlook 联系人中)。
  • 此联系人项目的电子邮件地址应该是 Exchange 用户(您组织中的任何人,但属于 Exchange 用户)的电子邮件。
  • 现在,当我选择此 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;
    

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

    最佳答案

    我找到了一种使用 ExchangeUser 项目并通过该对象解析 smtp 地址的方法。这篇文章有帮助 - Get Smtp email from ContactInfo stored in Exchange

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

    关于ms-office - 获取作为交换用户的收件人的电子邮件地址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6219665/

    相关文章:

    c# - Windows 7 64 位和 Office 64 位上的 LinqToExcel

    .net - VSTO 对 COM 对象/内存使用的引用

    c# - 如何查明 VSTO 中的应用程序是否繁忙

    outlook-addin - 日历概述上的 Outlook 加载项按钮

    c# - 为什么使用 GMAIL : text/html; is missing when use MailItem in Outlook plugin, GMAIL.COM 的 SMTP 服务器对 header 内容类型 : SMTP. 进行编码?

    c# - 为什么 VSTO Word ContentControl 没有 Name 属性?

    ms-word - Word 2013 中的引号问题

    vba - 如何在microsoft access中动态加载、 Access 和卸载子表单

    c# - 如何检索邮件项目的 Outlook 文件夹 (Outlook.MailItem)?

    outlook-addin - 将 ics 文件导入 Outlook.AppointmentItem