none
Which one to use for getting smtp address of receipent of appointment item

    Frage

  • Hi,

    In order to extract primary smtp address from a receipient of appointment item, I have found two ways

    1) _appItem.Recipients[i].Address

    2) _appItem.Recipients[i].PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x39FE001E")

    From the above two which one is preferable. From the first one for a specific user recently I'm facing the issue of getting smtp address as '

    (/o=Ameriprise/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Recipients/cn=smmulca488

    '. Could you please suggest me how to proceed further on this.

    Thank you in advance.

    Thanks,

    Gopi Santosh Boni


    Gopi Santosh Boni

    Dienstag, 2. Juli 2013 14:55

Antworten

  • Gopi,

    In order to determine the SMTP address for a mail item/appointment item, you can use the SenderEmailAddress property of the MailItem object. However, if the sender is internal to your organization, SenderEmailAddress does not return an SMTP address, and you must use the PropertyAccessor object to return the sender’s SMTP address - this way you can overcome the issue. It works for me locally. So you can try the following code snippet (C#.Net) and see whether it helps you to move ahead or not.

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

    Let me know how it goes.


    DeVa, M.S., {MSFT} Please remember to mark the replies as answers if they help


    Mittwoch, 10. Juli 2013 01:31

Alle Antworten

  • Hi,

    Please help me on the above question.

    Thank you in advance.

    Thanks,

    Gopi Santosh Boni


    Gopi Santosh Boni

    Mittwoch, 3. Juli 2013 10:09
  • Hello,

    Thank you for your post.

    This is a quick note to let you know that we are performing research on this issue.

    Cheers,
    Tony Chen
    Forum Support
    ________________________________________
    Come back and mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback on our support, please contact tnmff@microsoft.com.

    Dienstag, 9. Juli 2013 02:04
    Moderator
  • Gopi,

    In order to determine the SMTP address for a mail item/appointment item, you can use the SenderEmailAddress property of the MailItem object. However, if the sender is internal to your organization, SenderEmailAddress does not return an SMTP address, and you must use the PropertyAccessor object to return the sender’s SMTP address - this way you can overcome the issue. It works for me locally. So you can try the following code snippet (C#.Net) and see whether it helps you to move ahead or not.

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

    Let me know how it goes.


    DeVa, M.S., {MSFT} Please remember to mark the replies as answers if they help


    Mittwoch, 10. Juli 2013 01:31
  • Just want to check with you, whether the above code helped you to move ahead or not.

    DeVa, M.S., {MSFT} Please remember to mark the replies as answers if they help

    Donnerstag, 11. Juli 2013 10:56
  • Thank you deva for your response,


    will it work for both outlook 2007 and 2010?

    what if there is change in below url in future?

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

    '

    Im getting the below address, though he is a normal user

    /o=Ameriprise/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Recipients/cn=smmulca488

    Thanks,

    Gopi Santosh Boni



    Gopi Santosh Boni

    Montag, 12. August 2013 09:04
  • Moreover im trying to fetch the recipents address not the sender address.

    Gopi Santosh Boni

    Montag, 12. August 2013 10:32