Outlook 如何获取发件人';如果用户是active directory用户,则为的电子邮件地址?

Outlook 如何获取发件人';如果用户是active directory用户,则为的电子邮件地址?,outlook,sender,Outlook,Sender,我正在使用Outlook::\u MailItem对象的get_SenderEmailAddress()获取发件人的电子邮件地址。但如果用户是active directory用户,则recipientitem.address如下所示:/o=organizationg/ou=exchange管理组/cn=recipients/cn=xxxxxxxxx 是否有其他方法获取发件人的电子邮件地址?看起来像是类型为“EX”(与“SMTP”相反)的完全有效的电子邮件地址 如果需要SMTP地址,请使用Mail

我正在使用Outlook::\u MailItem对象的get_SenderEmailAddress()获取发件人的电子邮件地址。但如果用户是active directory用户,则recipientitem.address如下所示:/o=organizationg/ou=exchange管理组/cn=recipients/cn=xxxxxxxxx


是否有其他方法获取发件人的电子邮件地址?

看起来像是类型为“EX”(与“SMTP”相反)的完全有效的电子邮件地址

如果需要SMTP地址,请使用
MailItem.Sender.GetExchangeUser().PrimarySmtpAddress
。准备好处理空值和异常。
但是首先检查
MailItems.SenderEmailType
属性-如果它是“SMTP”,您仍然可以使用
SenderEmailAddress

我正在使用它来获取发件人邮件地址

 private string GetSenderSMTPAddress(Outlook.MailItem mail)
    {
        try
        {
            string PR_SMTP_ADDRESS =
                    @"http://schemas.microsoft.com/mapi/proptag/0x39FE001E"; if (mail == null)
            {
                throw new ArgumentNullException();
            }
            if (mail.SenderEmailType == "EX")
            {
                Outlook.AddressEntry sender =
                    mail.Sender;
                if (sender != null)
                {
                    //Now we have an AddressEntry representing the Sender
                    if (sender.AddressEntryUserType ==
                        Outlook.OlAddressEntryUserType.
                        olExchangeUserAddressEntry
                        || sender.AddressEntryUserType ==
                        Outlook.OlAddressEntryUserType.
                        olExchangeRemoteUserAddressEntry)
                    {
                        //Use the ExchangeUser object PrimarySMTPAddress
                        Outlook.ExchangeUser exchUser =
                            sender.GetExchangeUser();
                        if (exchUser != null)
                        {
                            return exchUser.PrimarySmtpAddress;
                        }
                        else
                        {
                            return null;
                        }
                    }
                    else
                    {
                        return sender.PropertyAccessor.GetProperty(
                            PR_SMTP_ADDRESS) as string;
                    }
                }
                else
                {
                    return null;
                }
            }
            else
            {
                return mail.SenderEmailAddress;
            }
        }
        catch (Exception ex)
        {
            return null;
        }
    }
可能重复的