"From" Field in MailMessage Is Null

I have come across an email that has a null for the from value. Looking in the headers entities Table I can see two entries. As you can see below the first entry is empty, however the second entry is a valid address. This is spam mail, but it would be nice to be able to extract any valid from addresses.



- Value Count = 0x00000002 object {System.Collections.ArrayList}

[0x00000000] “” object {string}

+ [0x00000001] {“Clever Grip” } object {Aspose.Email.Mail.MailAddress}



Thank you for any help.

Hi Jon,


Thank you for posting your query.

Can you please share your sample message file with us for our investigation? We need it in order to process it at our end and investigate the issue. We shall examine this use case and share our feedback with you.

Here is the junk mail from Thunderbird.

Hi Jon,


I have tested the sample using latest version Aspose.Email for .NET 5.4.0 and observed that there is only one From value and Display name. Could you please test the scenario with the latest version and let us know the feedback?

If issue is still there please share the code or tool which is used to view this property. It will help us to analyse the problem and provide assistance accordingly.

I have attached a text file with more information and a gif to see what the data looks like in Thunderbird. The version currently used is 5.4.0.



Thank you

Hi Jon,


I have checked the junk.eml file attached here, however it seems that its subject and contents are different than the image present here, and information provided in the first post. Could you please verify that correct EML is sent for analysis?

I have exported the message from Thunderbird to an eml. I tested the message using



MailMessage msg = MailMessage.Load(@“C:\Spring2015\The smart phone clip with the super strong grip.eml”);



The from field is still null and the entries table for ‘from’ shows an array of 2, the first which is null but the second a valid address.



I hope having only the single eml will help you recreate the issue.



Thank you for your time.

Hi Jon,

This is a malformed EML file that has multiple From fields. Please open this EML file in notepad and you will be able to identify the problem. There is a blank From field prior to the correct From field in the EML. As you remove this, the API correctly reads the EML information from the EML. Please verify it at your end and let us know your feedback.

Yes, this is spam that was received. When trying to extract all the message for forensic examination this message has no from field. If you note the image from Thunderbird, they can get to the second from address. Even your own data structure ‘entries table’ has the second address. If I could just get to the table, I can handle the case (or at least attempt a recovery) where the from address in null.

Hi Jon,

We have discussed this specific use case with our Product team and we are sorry to share that such case can’t be handled in the API as it violates the RFC standard. Please feel free to share your feedback with us if you have any other query about this.

Thank you, I understand.



This created additional work since I had to retrieve the from field using

Headers.Get(“From”), skip the empty field by removing the beginning comma and then create a uudecoder to convert the string to a Unicode address.



Maybe in the future a class will exist to help handle message that are deliberately malformed by spammers/hackers.

Hi Jon,

We have forwarded your this requirement to our product team so as to discuss if it is possible to provide such a class that can provide such information. As soon as we hear back, we shall write back here to update you.

Hi Team,

We have few MSG files where on conversion to PDF via MHTML format, the “From” field is missing.

  • Does the issue relate to corrupt msg file? (From field is available if msg is saved from outlook on different device)
  • Or is there any other workaround for this?

I have attached respective msg & pdf below.

From field missing MSG to PDF.zip (239.7 KB)

Please let me know if more details are required. Thanks.

@mkyadavAtvera,
Thank you for posting the query. Unfortunately, your MSG file does not contain “From” data. You can verify it as shown below:

MailMessage message = MailMessage.load("Email with unsecure attachments.msg");

System.out.println("From:");
System.out.println(message.getFrom());
System.out.println();

System.out.println("Headers/From:");
String[] fromValues = message.getHeaders().getValues("From");
if(fromValues != null) {
    for (String from : fromValues) {
        System.out.println(from);
    }
}

API Reference: MailMessage Class