Hi,
Hi Fred,
Thanks for considering Aspose.
The smtp address of sender should be accessible by MapiMessage.SenderEmailAddress property. I used the following code to download the message and display the address:
ExchangeClient client = new ExchangeClient(mailboxUri, credential);
// get mailbox info
ExchangeMailboxInfo mailbox = client.GetMailboxInfo();
// list inbox items
ExchangeMessageInfoCollection msgInboxCollection = client.ListMessages(mailbox.InboxUri);
foreach (ExchangeMessageInfo msgInboxInfo in msgInboxCollection)
{
MailMessage msg = client.FetchMessage(msgInboxInfo.UniqueUri);
MapiMessage mapiMsg = MapiMessage.FromMailMessage(msg);
MessageBox.Show(mapiMsg.SenderEmailAddress);
}
The original question was not about getting that information from an Exchange mailbox, but rather from a saved .msg file.
The SenderEmailAddress does not return the SMTP email address from the sender if the sender is from within the organization. I have not yet seen this done in any sample code, from Aspose or from anyone else using MAPI Messages. I tend to believe it’s not possible and that information is tucked inside Exhange or ActiveDirectory and you only have access to it if you have access to the Exchange server.
Hi,
It doesn’t work this way, because it gets not the SMTP address like ‘name@domain.com’, but the Exchange address like this 'Name </O=FIRM/OU=ADMINISTRATIVE GROUP/CN=RECIPIENTS/CN=NAME>'
If I load the mail file with MapiMessage class and debug through the headers, the “from”-header holds the right value.
And if I load an Email with Aspose and save it again as a .MSG file and open this file with Outlook, so it shows this Exchange address in the “From” box.
Hi Stas,