简体   繁体   English

如何获取发件人Outlook / Exchange的SMTP地址

[英]How to get the SMTP Adress of the sender outlook / Exchange

I am trying to get the SMTP Adress of the sender in an outlook plugin. 我正在尝试在Outlook插件中获取发件人的SMTP地址。 This worked as expected when I follow the examples from MSDN like this one here : 这和预期一样,当我跟随从MSDN像例子这样一个位置

private void GetSMTPAddressForRecipients(Outlook.MailItem mail)
{
    const string PR_SMTP_ADDRESS =
        "http://schemas.microsoft.com/mapi/proptag/0x39FE001E";
    Outlook.Recipients recips = mail.Recipients;
    foreach (Outlook.Recipient recip in recips)
    {
        Outlook.PropertyAccessor pa = recip.PropertyAccessor;
        string smtpAddress =
            pa.GetProperty(PR_SMTP_ADDRESS).ToString();
        Debug.WriteLine(recip.Name + " SMTP=" + smtpAddress);
    }
}

But since some time (some weeks) the reference schema at 但是由于一段时间(几周)以来的参考架构

http://schemas.microsoft.com/mapi/proptag/0x39FE001E

can not be resolved anymore. 无法解决了。 Errormessage : 错误消息

System.Runtime.InteropServices.COMException: http://schemas.microsoft.com/mapi/proptag/0x39FE001E Property unknown or ca not be found.

If I try the URL in a browser I get: 如果在浏览器中尝试该URL,则会得到:

The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

All examples I can find (for office 2013 and above) are pointing to ressources at http://schemas.microsoft.com/mapi/proptag/SOMETHING 我可以找到的所有示例(针对Office 2013及更高版本)都指向资源, 网址http://schemas.microsoft.com/mapi/proptag/SOMETHING

I also could not find any info in forums or oon MSDN that this moved or changed .. 我也没有在论坛上或在MSDN上找到任何移动或更改的信息。

Is anyone else running into this ? 还有其他人遇到这个吗? Is ther a known solution or workaroud. 是已知的解决方案还是可行的方法?

http://schemas.microsoft.com/mapi/proptag/0x39FE001E is not a link, it the actual DASL property name that the PropertyAccessor object expects. http://schemas.microsoft.com/mapi/proptag/0x39FE001E不是链接,它是PropertyAccessor对象期望的实际DASL属性名称。 The format is different for the fixed and named MAPI properties (eg http://schemas.microsoft.com/mapi/id/{00062008-0000-0000-C000-000000000046}/85100003 ). 固定和命名MAPI属性的格式是不同的(例如, http://schemas.microsoft.com/mapi/id/{00062008-0000-0000-C000-000000000046}/85100003 : http://schemas.microsoft.com/mapi/id/{00062008-0000-0000-C000-000000000046}/85100003 {00062008-0000-0000- http://schemas.microsoft.com/mapi/id/{00062008-0000-0000-C000-000000000046}/85100003 }/ http://schemas.microsoft.com/mapi/id/{00062008-0000-0000-C000-000000000046}/85100003 )。
You can look at the MAPI properties and their DASL names in OutlookSpy (click IMessage button). 您可以在OutlookSpy中查看MAPI属性及其DASL名称(单击IMessage按钮)。

Also keep in mind that you should not expect any particular MAPI property to be present - they are not guaranteed to be present and you must expect and handle errors returned by the PropertyAccessor object. 还请记住,您不应期望存在任何特定的MAPI属性-不保证它们会存在,并且您必须期望并处理PropertyAccessor对象返回的错误。

In your particular case, you can are not checking the SMTP address of a sender, you are working wit the message recipients. 在特定情况下,您无法检查发件人的SMTP地址,而是与邮件收件人一起工作。 For the recipients, check if the PR_SMTP_ADDRESS property is there. 对于收件人,检查PR_SMTP_ADDRESS属性是否存在。 If not, open the adders entry (Recipient.AddressEntry) and check for that property from the AddressEntry. 如果没有,请打开加法器条目(Recipient.AddressEntry),然后从AddressEntry中检查该属性。 You can also check for the presence of the PR_EMS_AB_PROXY_ADDRESSES multivalued property (an array is returned). 您还可以检查是否存在PR_EMS_AB_PROXY_ADDRESSES多值属性(返回一个数组)。 You can so try AddressEntry.GetExchangeUser().PrimarySmtpAddress (be prepared to handle errors and nulls). 您可以尝试使用AddressEntry.GetExchangeUser()。PrimarySmtpAddress(准备处理错误和空值)。 Once again, take a look at the message with OutlookSpy to see which property is present. 再次使用OutlookSpy查看该消息,以查看存在哪个属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 C# VSTO Outlook 插件 - 如何使用传出 Z0C83ZEFA57C7831CEB7B24 获取发送方的 email 地址? - C# VSTO Outlook plugin - How can I get the email address of the sender of an outgoing email using Exchange? 如何使用Outlook互操作检索发件人的SMTP电子邮件地址? - How to retrieve the sender smtp email address with Outlook interop? Outlook SMTP /交换行为差异 - Outlook smtp/exchange behavior differences Outlook帐户-如何获取Exchange电子邮件地址? - Outlook Accounts - How to get the Exchange Email address? 如何获取带有Outlook加载项的电子邮件的SMTP标头? - How to get the SMTP header of an email with an outlook add in? Outlook联系人无法获取SMTP地址,“交换”联系人列表上没有MAPI属性 - outlook contact can't get SMTP address, No MAPI properties on “exchange” contact list 如何从Outlook获取发件人的电子邮件地址? - How to get the sender's email address from Outlook? Outlook的电子邮件类型为EX时如何获取发件人的电子邮件? - How to get sender's email when Email type is EX for Outlook? 如何使用Outlook互操作获取转发电子邮件的原始发件人? - How to get original sender of a forwarded email with Outlook interop? 如何获取Outlook.MeetingItem的发件人ExchangeUser和邮件地址 - How to get sender ExchangeUser and mailaddress for Outlook.MeetingItem
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM