We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Get Sender SMTP address from .msg file


I’m working with MapiMessage class to retrieve informations from .msg files.
I’m able to get smtp recipient addresses by using PropertyStream and the right MAPI property (because the MapiMessage’s EmailAddress property may return an Exchange Address… ). It works fine.

Now, I’d like to do the same with the sender’s email address. But I really dont find how to get his SMTP (not the exchange one) address…

Have you got any leads ?



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:

NetworkCredential credential = new NetworkCredential(username, password, domain);
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);

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.


Thank you for inquiry.

The sender’s address from a saved MSG file can be get using both MailMessage and MapiMessage classes.

MailMessage msg1 = MailMessage.Load(“test.msg”, MessageFormat.Msg);

MapiMessage mapiMsg = MapiMessage.FromFile(“test.msg”);

In the previous post, I posted the code sample to first connect and download the message from an Exchange Server and then get the sender’s address.

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,

Thank you for your interest.

Can you please post your issue in a new thread so we may investigate it properly? Please also share your sample message files for our review.