I am trying to get the SMTP Address for an email and I have written a code to avoid getting the x.500 address. I get the SMTP address by accessing PropertyAccessor.GetProperty(PR_SMTP_ADDRESS)
where PR_SMTP_ADDRESS = @"http://schemas.microsoft.com/mapi/proptag/0x39FE001E"
;
However, this works on some laptops while some give an error saying
"The property http://schemas.microsoft.com/mapi/proptag/0x39FE001E is unknown or cannot be found."
Any idea how to resolve this?
If you want the SMTP address , you can create an Outlook.Recipient
from the X.500 and resolve the Recipient.AddressEntry
to an Outlook.ExchangeUser
.
string address = string.Empty;
Outlook.Recipient recipient = mailItem.Application.Session.CreateRecipient(mailItem.SenderEmailAddress);
if (recipient != null && recipient.Resolve() && recipient.AddressEntry != null)
{
Outlook.ExchangeUser exUser = recipient.AddressEntry.GetExchangeUser();
if (exUser != null && !string.IsNullOrEmpty(exUser.PrimarySmtpAddress))
address = exUser.PrimarySmtpAddress;
}
The error you are receiving with PR_SMTP_ADDRESS
indicates that the MIME property isn't present in the mail message properties and you need an alternate means to determine the senders SMTP address. You cannot assume a MIME property will always be present.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.