简体   繁体   中英

Retrieve Email Information from .EML Files

I have a .eml files. What I want to do is to retrieve the From, To, Subject, Body & attachments(if any) from this .eml file and save to database. I need to do that in C# and without any third party applications.

I searched for some source code, but couldn't find any, except this Is it possible to read .eml files in .net But there is no source code, which is more helpful.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM