Free Support Forum -

Reading from address of MSG file

We have a solution where users save email messages from their outlook in MSG format. Then there is another process that picks up these files, reads (through Aspose) the data inside and updates metadata e.g. From/To/Subject etc.

This worked fine mostly until:
we found a few emails with the from address being read like below:
instead of
Firstname Lastname

We were able to reproduce this consistently when we saved email messages from the Sent Items (in Outlook). It works perfectly fine when we saved emails from the Inbox

Any idea why this is happening and how this could be resolved would be much appreciated.


Thank you for using Aspose.Email.

The format of the email address that you have got is referred to as Exchange format. It is an expected behavior if the message does not have address in smtp format. If a message’s SenderAddressType is equal to “EX” i.e. Exchange, the SenderEmailAddress property will return Sender’s SMTP address instead of PR_SENDER_EMAIL_ADDRESS property. Moreover, PR_SENDER_EMAIL_ADDRESS may be missing as well in some cases.

If message contains SMTP format address, you could use the following code to get the proper email address:

<span style=“font-size:10.0pt;line-height:115%;font-family:
“Courier New”;color:blue;mso-no-proof:yes”>string<span style=“font-size:
10.0pt;line-height:115%;font-family:“Courier New”;mso-no-proof:yes”> s =


I would like to further share with you that you can use the MapiNamedProperty in some cases as a work around to get the From address, as follow:

<span style=“font-size:
10.0pt;font-family:“Courier New”;color:blue;mso-no-proof:yes”>foreach<span style=“font-size:10.0pt;font-family:“Courier New”;mso-no-proof:yes”> (MapiNamedProperty namedProperty in mapiMessage.NamedProperties.Values)<o:p></o:p>


if (namedProperty.Oom == "InetAcctName")


string senderEmail = namedProperty.GetString();



Hi Kasif,

Thanks for your posts. I tried your solution but this did not work.

I have the msg file in a filestream.
The code is now like this :

MapiMessage mapiMessage = MapiMessage.FromStream(_msgStream);

string From = MapiMessage.TryGetPropertyString(MapiPropertyTag.PR_SENDER_EMAIL_ADDRESS);

Anything I am doing incorrect here ?

If any help I would explain that again: The user saves and msg file from Outlook (can be either inbox or sent items). Once saved, a totally independent service picks up the msg file as a filestream, and parses through the meta data to update the database. I tried your work around through the code above, and got the exact same result I was getting before.

Any ideas ?


Actually it made it worse. Now emails saved from the Inbox are coming up with the wrong address too. :frowning:


Thank you for the feedback.

As I shared earlier if a message does not contain the sender email address in SMTP format, then we can only extract this information by using either Directory Services or by Outlook Object Model. Can you please share a sample MSG file here for our further investigation, though we believe the messages are missing the email address in SMTP format, thus returning the Exchange format address.

Hi Kashif,

Thanks for replying. I have attached the two msg files one working and the other not working. They are essentially the same email, sent to myself, the one not working was saved from my Sent Items in Outlook.

Looking forward to hear back from you soon.


Hi Shah,

Thank you for sharing the sample files.

After analyzing your attached files, we have found that the Message, that is not working, does not contain the SMTP format address. The PR_SENDER_ADDRTYPE contains “EX”, but since the message is missing the SMTP format address, so it returns the Exchange format address for the From field.

You can analyze these properties using Outlook Spy and get an idea about the missing information. For the message file, that is working, contains the tag PidTagSenderSmtpAddress_W whose value is set to the sender’s email address and then displayed. In messages, where this is missing, the PR_SENDER_ADDRESS can not display the SMTP address, and the Exchange format address is returned.

Hi Kashif,

Thanks for your reply.

I understand now how to check if information is missing. But that does not solve my problem. Would be helpful if you can suggest how to extract the sender’s name/email address from the file. Is there any way, either by reading the file somewhat different or making changes on my Outlook/Exchange I can get the sender’s email address in the right format ?

I do not intend to install Outlook APIs or AD queries on my server, where this service is running. That was our main intention of purchasing Aspose, to not install Outlook on my server.


Thank you for the feedback.

As you told earlier that messages are saved from Outlook (which I assume is configured to your Exchange server), so it seems something to be at Outlook/Exchange server end. Can you please reconfirm to us that your Outlook is configured with Exchange server and messages are saved from Outlook’s sent item folder locally?

Also, for your requirements, you can also use Aspose.Email API to fetch the messages/information from the Exchange server’s Sent Items folder and check its “From” field, in addition to saving, as follow:

<span style=“font-size:
10.0pt;font-family:“Courier New”;color:blue;mso-no-proof:yes”>const<span style=“font-size:10.0pt;font-family:“Courier New”;mso-no-proof:yes”> string mailboxUri = “you exchange
URI here”

const string domain = @"";

const string username = @"username";

const string password = @"password";

NetworkCredential credential = new NetworkCredential(username, password, domain);

using (ExchangeWebServiceClient client = new ExchangeWebServiceClient(mailboxUri, credential))


// Call ListMessages method to list messages info from Inbox

ExchangeMessageInfoCollection msgCollection = client.ListMessages(client.MailboxInfo.SentItemsUri);

/// Loop through the collection to get Message URI

foreach (ExchangeMessageInfo msgInfo in msgCollection)


string strMessageURI = msgInfo.UniqueUri;

MailMessage msg = client.FetchMessage(strMessageURI);


msg.Save(msg.Subject + ".msg", MailMessageSaveType.OutlookMessageFormatUnicode);



We request you to please give this code a try at your end with your Exchange server and let us know if it fetches the "From" field properly. There are some other articles also available in our online documentation section that you can refer to for further programming samples using Exchange Server.

In case this is not helpful, please share your Exchange Server information with us in addition to any other information that can be of further help to us.

Hi Shah,

I have received your concerns that you have raised with our sales team. Please accept our apologies for the inconvenience you are facing.

I have forwarded your requirements to our development team along with the sample MSG files that you shared with us earlier. I have also increased the priority of this issue so as to sought quick support from our development team in this respect. We will soon share our findings with you here after getting updates from our development team.

The issue has been logged as: NETWORKNET-33491 in our issue tracking system.

Hi Kashif,

Thanks for your reply. I appreciate you escalating the issue. We are looking forward to hear back with a suitable solution.

Hi Shah,

You are welcome.

We will update you about our findings soon. If there needs to be any configuration set up at Outlook/Exchange end that can solve this issue, we will provide you details about it as well. Your patience in this regard is highly appreciated.

Hi Shah,

Thank you for your patience while our development team investigated this issue.

After further analyzing the provided files, we were not able to find any such information from which we could extract the “From” address in Smtp format. We are sorry, but this is not a limitation on Aspose.Email end, as the source MSG files are missing this information.

In such a situation, if you have access to exchange server, you can retrieve the “From” address with ExchangeWebServiceClient using the Contact Name. But in case you don’t have access to the Exchange Server, you can try connect outlook to your Exchange server using POP3 or IMAP protocols, and see if that solves your issue.

Hi Kashif,

It is sad to see that we paid so much for a system, that does not solve our problem. As I said earlier to you and to Adam, if we needed to query the exchange server to get information, we would not need to buy Aspose, we could just do that ourselves, and avoid buying an expensive software with limitations.

The unfortunate bit is the limitation of your program is not mentioned a disclaimer that it does not work on certain cases. If we read that we possibly would not have paid for an expensive product.

Not a very happy customer.

Hi Shahriar,

Thanks for voicing your concerns here. We will have an internal discussion with various members including product management and see what can be done with the issue at hand here.

Please give us some time and we will get back to you with some further feedback.


Hi Shahriar,

Thanks for waiting

We have further discussed this issue and have come to the conclusion that the outcome and information supplied to you is correct. As Kashif has explained already, the problem you are facing is a limitation of the file format and not of the Aspose.Email API. The email message you are processing simply doesn’t store the address. If you need to look up the address from the exchange server then you can do so using the Aspose.Email API. The code to achieve this has been supplied in this thread here.

Although we strive to document any potential limitations of our components, this is not a limitation of the Aspose.Email API, rather of the file format.

We apologise for any inconvenience.