none
The property "http://schemas.microsoft.com/mapi/proptag/0x39FE001E" is unknown or cannot be found. RRS feed

  • Question

  • I am using the below sample method to get the SMTP address of a recipient.

    using Outlook = Microsoft.Office.Interop.Outlook;

    privatevoid GetSMTPAddressForRecipients(Outlook.MailItem mail) { conststring 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(); //error Debug.WriteLine(recip.Name + " SMTP=" + smtpAddress); } }

    I am getting the below error in the above highlighted line of code.
    The property "http://schemas.microsoft.com/mapi/proptag/0x39FE001E" is unknown or cannot be found.

    Any idea how to fix this problem. Thanks a lot for your time and help in advance.



    http://www.selvaonline.com - Live a Happy & Balanced Life

    Wednesday, May 14, 2014 6:15 PM

Answers

  • Did you try to use the code listed in the article I mentioned above?

    private string GetSenderSMTPAddress(Outlook.MailItem mail)
    {
        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;
        }
    }
    
    

    Wednesday, May 14, 2014 8:21 PM

All replies

  • It looks like there is no such property defined. Did you try to use Outlook Spy or MFCMapi for exploring existing properties?
    Wednesday, May 14, 2014 6:22 PM
  • When i search for "http://schemas.microsoft.com/mapi/proptag/0x39FE001E", i am getting the below message

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

    So this code will not throw any error?

    http://www.selvaonline.com - Live a Happy & Balanced Life

    Wednesday, May 14, 2014 6:39 PM
  • Did you try to use Outlook Spy or MFCMapi for exploring existing properties?
    Wednesday, May 14, 2014 7:13 PM
  • Nope. I am not using any other api's other than outlook object model.

    http://www.selvaonline.com - Live a Happy & Balanced Life

    Wednesday, May 14, 2014 7:33 PM
  • Did you try to use the code listed in the article I mentioned above?

    private string GetSenderSMTPAddress(Outlook.MailItem mail)
    {
        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;
        }
    }
    
    

    Wednesday, May 14, 2014 8:21 PM
  • OutlookSpy is not a separate library or an API - it is a tool to help you see what is going on in Outlook.

    Keep in mind that PR_SMTP_ADDRESS property is not guaranteed to be present - you should expect and handle that error.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Thursday, May 15, 2014 4:31 AM