Is it possible to read .eml files in .net
Yes you can. They are just regular text files, nothing fancy.
This is what an eml file looks like on the inside
X-Sender: somewhere@google.com
X-Receiver: somewhere@google.com
MIME-Version: 1.0
From: somewhere@google.com
To: somewhere@google.com
Date: 7 Jun 2009 18:58:01 -0400
Subject: From someone you know
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: quoted-printable
This is the body
Retrieve Email Information from .EML Files
Refer Following link urgently:
http://www.codeproject.com/Articles/76607/Easily-Retrieve-Email-Information-from-EML-Files-R
protected CDO.Message ReadMessage(String emlFileName)
{
CDO.Message msg = new CDO.MessageClass();
ADODB.Stream stream = new ADODB.StreamClass();
stream.Open(Type.Missing, ADODB.ConnectModeEnum.adModeUnknown, ADODB.StreamOpenOptionsEnum.adOpenStreamUnspecified, String.Empty, String.Empty);
stream.LoadFromFile(emlFileName);
stream.Flush();
msg.DataSource.OpenObject(stream, "_Stream");
msg.DataSource.Save();
return msg;
}
You can also get help for elm parsing from:
http://blog.onderweg.eu/2010/12/parsing-eml-files-in-c/
This is also useful tutorial:
http://www.emailarchitect.net/eagetmail/kb/csharp.aspx?cat=18
Saving emails to .eml file using specifiedPickupDirectory creates double decimal points in email body
As I understand it, this is to be expected as the file produced is not supposed to be a straight copy but rather follow the rfc822 spec (see http://www.w3.org/Protocols/rfc822/3_Lexical.html).
If you want to compare the file output with your input, then I think you will need to find/write a routine to decode the rfc822 back to plain test.
Related Topics
Comparing Floating Point Values
How to List Available Video Modes Using C#
Better Way to Cast Object to Int
Restsharp Simple Complete Example
Entity Framework - Add Navigation Property Manually
Play Multiple Sounds Using Soundplayer
C# Random Numbers Aren't Being "Random"
What Is the Meaning of Thread-Agility in ASP.NET
Generate 16-Bit Grayscale Bitmapdata and Save to File
Jquery Ajax Call to an ASP.NET Webmethod
How to Write the Escape Char '\' to Code
Does C# Support Project-Wide Default Namespace Imports Like Vb.Net
Linq Order By, Group by and Order by Each Group
How to Get a Combination of Keys in C#
How to Find the Actual Printable Area? (Printdocument)