【问题标题】:Trying to get SMTP Addresses from all AppointmentItem Recipients尝试从所有 AppointmentItem 收件人获取 SMTP 地址
【发布时间】:2022-04-20 12:55:57
【问题描述】:

我迭代所有 AppointmentItem.Recipients。对于每个收件人,我使用以下实用程序方法来检索收件人“正常”的 SMTP 电子邮件地址:

为此,我使用了来自 stackoverflow 的帖子:Getting email address from a Recipient object

    public static string GetSmtpAddress(Outlook.AddressEntry addressEntry)
    {
        String smtpAddress;

        if (addressEntry.Type == "EX")
        {
            if (addressEntry.AddressEntryUserType == Outlook.OlAddressEntryUserType.olExchangeUserAddressEntry
                 || addressEntry.AddressEntryUserType == Outlook.OlAddressEntryUserType.olExchangeRemoteUserAddressEntry)
            {
                Outlook.ExchangeUser user = addressEntry.GetExchangeUser();
                smtpAddress = user != null ? user.PrimarySmtpAddress : null;
            }
            else if (addressEntry.AddressEntryUserType == Outlook.OlAddressEntryUserType.olOutlookContactAddressEntry)
            {
                //returns the actual contact but it has 3 email properties (Email1Address, Email2Address, Email3Address). 
                //How to identify which email has the user selected

                Outlook.ContactItem cont = addressEntry.GetContact();
                String OABID = addressEntry.ID;
                String typ = OABID.Substring(29 * 2, 2);
                if (typ=="00")
                {
                    smtpAddress = cont.Email1Address; <!-- Strange Emailadress
                }else if (typ=="01")
                {
                    smtpAddress = cont.Email1Address;
                } else
                {
                    smtpAddress = cont.Email2Address;
                }
            } else
            {
                smtpAddress = "";
            }
        }
        else if (addressEntry.Type == "SMTP")
        {
            smtpAddress = addressEntry.Address;
        }
        else
        {
            smtpAddress = "";
        }
        return smtpAddress;
    }

标有

我正在寻找的是一个 100% 强大的实用程序功能,无论收件人是什么地址类型、Exchange 用户、地址簿用户或其他任何类型,它都能检索正确的 SMTP 地址。非常感谢任何帮助。

最好的问候 汉内斯

【问题讨论】:

    标签: vsto outlook-addin


    【解决方案1】:

    如果 GAL 条目不再存在,则所有赌注都将取消。在接触Recipient.AddressEntry 之前,请检查收件人表中是否有可用的SMTP 地址 - 使用Recipient.PropertyAccessor.GetProperty 读取PR_SMTP_ADDRESS 属性(DASL 名称"http://schemas.microsoft.com/mapi/proptag/0x39FE001F")。如果它不存在,请阅读 PR_ADDRTYPE 属性 ("http://schemas.microsoft.com/mapi/proptag/0x3002001F") - 这相当于 AddressEntry 对象上的 Type 属性,不幸的是 Recipient 对象没有公开。如果是“SMTP”,只需使用Recipient.Address 属性。如果不是,请使用上面需要Recipient.AddressEntry 的函数。

    查看与OutlookSpy 的约会(我是它的作者) - 单击 IMessage 按钮,转到 GetRecipientTable 选项卡以检查 PR_SMTP_ADDRESS 属性是否可用

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-05-13
      • 2013-09-13
      • 2013-12-26
      • 2022-07-26
      • 2015-12-23
      • 1970-01-01
      • 2015-07-22
      相关资源
      最近更新 更多