Retrieving Email Information from .EML Files

I have .eml files. I want to do this in order to extract From, To, Subject, Body objects and attachments (if any) from this .eml file and save them to the database. I need to do this in C # and without any third party applications.

I was looking for some source code, but could not find, besides this. Is it possible to read .eml files in .net But the source code is not more useful.

+6
source share
1 answer

Refer to the 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 analysis with:

http://blog.onderweg.eu/2010/12/parsing-eml-files-in-c/

This is also a useful tutorial:

http://www.emailarchitect.net/eagetmail/kb/csharp.aspx?cat=18

+9
source

All Articles