Benutzer mit den meisten Antworten
Which one to use for getting smtp address of receipent of appointment item

-
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
Frage
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
- Bearbeitet Deva [MSFT]Microsoft employee Mittwoch, 10. Juli 2013 01:32 update
- Als Antwort vorgeschlagen Deva [MSFT]Microsoft employee Freitag, 12. Juli 2013 17:20
- Als Antwort markiert Judy_ZhouMicrosoft employee, Moderator Mittwoch, 31. Juli 2013 03:58
Alle Antworten
-
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. -
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
- Bearbeitet Deva [MSFT]Microsoft employee Mittwoch, 10. Juli 2013 01:32 update
- Als Antwort vorgeschlagen Deva [MSFT]Microsoft employee Freitag, 12. Juli 2013 17:20
- Als Antwort markiert Judy_ZhouMicrosoft employee, Moderator Mittwoch, 31. Juli 2013 03:58
-
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