How to read only headers from EML file

Hi,


I need to read a lot of messages (thousands) in EML format and get basic information from headers (no need to read the rest of the message - only headers).

There is memory consumption issue that I reported before, when reading 75 MB message using MailMessage class requires more than 300MB of RAM. So reading a lot of messages simultaneously sometimes results in OutOfMemory exception.

My question: Is there any lightweight reader that allows to read only message headers?

Thanks,
Alex

Hi Alex,


Thank you for writing to Aspose support team again.

I have checked the documentation but afraid to share that no such option is available where only headers from an email can be loaded. You have to load the complete message for reading the headers.

Please feel free to write us back if you have any other query in this regard.

Hi Kashif,

Want to ask if you found such functionality useful (to analyze just headers and provide information about recipient addresses and message subject, without reading attachments and etc). If this is something you are happy to add then we glad to share our vision/requirements of this functionality. If you do not see this request reasonable - just let us know.


Many thanks,
Alex Shloma

Hi Alex,


We have discussed this with our Product team and this can be considered further. Please share your vision/requirements in detail with us so these can be shared accordingly with the team. We look forward to assist you further in this regard.

Hi,

Here is how I see this functionality.

  • Dedicated class, say EmlHeadersReader.
  • Static method that takes one parameter - path to EML file or stream.
  • Methods return instance of HeaderCollection class.
  • Internally methods read only headers - reader stops after finding empty line (see picture). In this case memory consumption is minimum.
  • GetDecodedValue and other logic works as though headers were read during loading entire message using MailMessage class.

Thanks,
Alex

Hi Alex,


Thank you for sharing your feedback.

We have forwarded your request to our Product team via issue id: EMAILNET-38680 for further consideration. Your provided information has also been logged against the mentioned ticket. We’ll update you here once there is further information or a fix version available in this regard.