This article is not the best way to do this. Please see EML_ReaderEx.aspx for a better way.
I know parsing .EML files is easy enough to do, but here it is in a wrapper class, all nice and tidy. This comes in real handy if you have a service that needs information that is emailed to the box. It has the usual "To", "CC" fields, along with a collection of x-receiver and many other fields. It will give you both plain text and HTML bodies, provided they are in the EML. Dates are converted to
Using the Code
To use this class, just get the
FileStream for the .EML file and put it in the constructor of the
FileStream fs = File.Open(sFile, FileMode.Open,
EMLReader reader = new EMLReader(fs);
Then, you just retrieve the email properties through the properties of the wrapper class.
foreach(string xReceiver in reader.X_Receivers)
I covered all the email fields that I was concerned about, but there may be some that were left out. However, adding support for new fields in
EMLReader is fairly straightforward.
Points of Interest
I worked on this at about the same time that I worked on a wrapper class for MSG files. Big difference in difficulty. Where the EML wrapper class maybe took a day to read the spec and get right, the MSG wrapper class took a week. Probably, most of that time was due to the rather large learning curve on understanding Compound Documents and how MSG uses them. What a mess, and all that for such a legacy format. If Microsoft were to do it today, I'm sure it would all be in XML (attachments might make it a little lengthy though).
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.