none
Outlook Property Accessor error RRS feed

  • Question

  • Hi,
    I'm using the Outlook property accessor to get the sender's smtp address.
    This is the Code that I'm using:

                         const string PR_SMTP_ADDRESS = "http://schemas.microsoft.com/mapi/proptag/0x39FE001E"; 
                         Microsoft.Office.Interop.Outlook.PropertyAccessor pa = recip.PropertyAccessor;
    
                        //Gets the email address for the recipients in the email
                        smtpAddress = pa.GetProperty(PR_SMTP_ADDRESS).ToString();

    It's reading fine for most of the emails, but for a couple of them, I get this error:
    The property "http://schemas.microsoft.com/mapi/proptag/0x39FE001E" is unknown or cannot be found.

    I want to know what's the fix for this error and if there are any workarounds if the error is thrown?

    Thanks


    Abhi

    • Moved by Bob Wu-MT Friday, April 27, 2012 6:14 AM (From:Windows Forms General)
    Wednesday, April 25, 2012 5:37 PM

Answers

  • PR_SMTP_ADDRESS *might* be available in the recipients table (but most of the time not on the AddressEntry object) in the cached mode.

    On a general note, not all MAPI properties are always present, so you must be prepared that the PropertyAccessor returns an error - this is perfectly normal.


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

    Friday, April 27, 2012 4:31 PM

All replies

  • Hi Abhi,
    According to your description, the issue is related to outlook development. I will move it to the Outlook for Developers Forum for better support.
    Best Regards,

    Bob Wu [MSFT]
    MSDN Community Support | Feedback to us

    Friday, April 27, 2012 6:13 AM
  • http://msdn.microsoft.com/en-us/library/ee692174.aspx, scroll down to GetSenderSMTPAddress sample function.
    Friday, April 27, 2012 6:36 AM
  • That property may or may not work depending on whether or not the sender is an Exchange user within your Exchange organization, and whether or not cached mode is being used with Exchange.
     
    You can check to see if the address type is SMTP by checking PR_SENDER_ADDRTYPE_W ("http://schemas.microsoft.com/mapi/proptag/0x0C1E001F"), a PT_UNICODE value. If the value is "SMTP" you need to use PR_SMTP_ADDRESS. If it's "EX" for Exchange you can use PR_SENDER_EMAIL_ADDRESS_W ("http://schemas.microsoft.com/mapi/proptag/0x0C1F001F").

    PR_SMTP_ADDRESS is not available in cached mode. You would use PR_EMS_AB_PROXY_ADDRESSES in cached mode, which is a PT_MV_STRING8 or PT_MV_UNICODE (string array) property.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "iconabhi114" <=?utf-8?B?aWNvbmFiaGkxMTQ=?=> wrote in message news:d1959e89-3cee-4dd7-a2fb-6eb7fb6e5c73...

    Hi,
    I'm using the Outlook property accessor to get the sender's smtp address.
    This is the Code that I'm using:

                         const string PR_SMTP_ADDRESS = "http://schemas.microsoft.com/mapi/proptag/0x39FE001E"; 
                         Microsoft.Office.Interop.Outlook.PropertyAccessor pa = recip.PropertyAccessor;
    
                        //Gets the email address for the recipients in the email
                        smtpAddress = pa.GetProperty(PR_SMTP_ADDRESS).ToString();

    It's reading fine for most of the emails, but for a couple of them, I get this error:
    The property "http://schemas.microsoft.com/mapi/proptag/0x39FE001E" is unknown or cannot be found.

    I want to know what's the fix for this error and if there are any workarounds if the error is thrown?

    Thanks


    Abhi


    Ken Slovak MVP - Outlook
    Friday, April 27, 2012 2:18 PM
    Moderator
  • PR_SMTP_ADDRESS *might* be available in the recipients table (but most of the time not on the AddressEntry object) in the cached mode.

    On a general note, not all MAPI properties are always present, so you must be prepared that the PropertyAccessor returns an error - this is perfectly normal.


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

    Friday, April 27, 2012 4:31 PM
  • If the sender EMail address is a Exchange address then fetching the MAPI_PR_SMTP_ADDRESS property from the AddressEntry object will return a value.

    However of the sender EMail address is a Internet Address then the above method will fail (as Dmitry  mentioned). In  this case one can use the SenderEmailAddress of the mail item.

    Ex:

    String senderEmailAddr;
    String senderEmailType = mailItem.SenderEmailType;
    
    // For Internet Addresses EmailType would be 'SMTP' whilst for Exchange Addresses the type will be 'EX'
    if ("EX".Equals(senderEmailType))
    {
    	Outlook.PropertyAccessor propertyAccessor = mailItem.Sender.PropertyAccessor;
    	senderEmailAddr = propertyAccessor.GetProperty(MAPI_PR_SMTP_ADDRESS) as String;
    }
    else if ("SMTP".Equals(senderEmailType))
    	senderEmailAddr = mailItem.SenderEmailAddress;
    /Artha Wijendra




    • Edited by Amavi Thursday, September 11, 2014 5:48 AM
    Thursday, September 11, 2014 5:36 AM