0

In my application, I need to validate if a particular file has a correct EML format. I thought about opening the file and check if it has the correct headers (subject,body,etc) but I'd like to know if there is a standard approach for this in C#.

For the record, the file could end with any possible extension and I don't intend to do anything special with the file, I just need to verify that the file is in a valid EML format.

TtT23
  • 6,876
  • 34
  • 103
  • 174
  • The RFC5322 requirements are not very stern, any text file with exactly one `From:` and `Subject:` header before the first empty line is basically game. You might also verify that all lines before the first empty adhere to the conventions for email headers - that the first whitespace is preceded by a colon. (The whitespace after the colon is actually optional, too.) – tripleee Jan 08 '13 at 05:22

1 Answers1

0

Easily Retrieve Email Information from .EML Files

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 DateTime.

http://www.codeproject.com/Articles/29439/Easily-Retrieve-Email-Information-from-EML-Files

andy
  • 5,979
  • 2
  • 27
  • 49