[英]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.