【问题标题】:How to get the SMTP Adress of the sender outlook / Exchange如何获取发件人outlook / Exchange的SMTP地址
【发布时间】:2018-05-13 09:36:35
【问题描述】:

我正在尝试在 Outlook 插件中获取发件人的 SMTP 地址。 当我按照 MSDN 中的示例进行操作时,这按预期工作 喜欢this one here

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

但自从一段时间(几周)以来,参考架构在

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

无法再解决。 错误消息

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

如果我在浏览器中尝试该 URL,我会得到:

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

我能找到的所有示例(对于 Office 2013 及更高版本)都指向 http://schemas.microsoft.com/mapi/proptag/SOMETHING 的资源

我也无法在论坛或 MSDN 上找到任何移动或更改的信息 ..

还有其他人遇到这个吗? 是否有已知的解决方案或解决方法。

【问题讨论】:

    标签: c# outlook smtp exchange-server outlook-addin


    【解决方案1】:

    http://schemas.microsoft.com/mapi/proptag/0x39FE001E 不是链接,它是PropertyAccessor 对象期望的实际DASL 属性名称。固定和命名 MAPI 属性的格式不同(例如 http://schemas.microsoft.com/mapi/id/{00062008-0000-0000-C000-000000000046}/85100003)。
    您可以在OutlookSpy 中查看 MAPI 属性及其 DASL 名称(单击 IMessage 按钮)。

    另外请记住,您不应期望任何特定的 MAPI 属性存在 - 它们不能保证存在,您必须预期并处理 PropertyAccessor 对象返回的错误。

    在您的特定情况下,您可以不检查发件人的 SMTP 地址,而是与邮件收件人合作。对于收件人,检查 PR_SMTP_ADDRESS 属性是否存在。如果没有,请打开加法器条目 (Recipient.AddressEntry) 并从 AddressEntry 检查该属性。您还可以检查是否存在 PR_EMS_AB_PROXY_ADDRESSES 多值属性(返回一个数组)。您可以尝试 AddressEntry.GetExchangeUser().PrimarySmtpAddress (准备好处理错误和空值)。 再次使用 OutlookSpy 查看消息以查看存在的属性。

    【讨论】:

    • 啊,好吧,所以如果它不存在,我必须检查其他属性。我会试试的。谢谢你。 Outlook spy 似乎是我迄今为止没有使用过的基础工具。认为现在也必须改变;)
    猜你喜欢
    • 2021-03-14
    • 2018-10-27
    • 2015-09-09
    • 1970-01-01
    • 2021-03-08
    • 1970-01-01
    • 2018-04-16
    • 2019-06-07
    • 1970-01-01
    相关资源
    最近更新 更多