1
votes

I am trying to get the SMTP Adress of the sender in an outlook plugin. This worked as expected when I follow the examples from MSDN like 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);
    }
}

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:

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

I also could not find any info in forums or oon MSDN that this moved or changed ..

Is anyone else running into this ? Is ther a known solution or workaroud.

1

1 Answers

2
votes

http://schemas.microsoft.com/mapi/proptag/0x39FE001E is not a link, it the actual DASL property name that the PropertyAccessor object expects. The format is different for the fixed and named MAPI properties (e.g. 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).

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.

In your particular case, you can are not checking the SMTP address of a sender, you are working wit the message recipients. For the recipients, check if the PR_SMTP_ADDRESS property is there. If not, open the adders entry (Recipient.AddressEntry) and check for that property from the AddressEntry. You can also check for the presence of the PR_EMS_AB_PROXY_ADDRESSES multivalued property (an array is returned). You can so try AddressEntry.GetExchangeUser().PrimarySmtpAddress (be prepared to handle errors and nulls). Once again, take a look at the message with OutlookSpy to see which property is present.