Home > .Net > Read outlook eml file without outlook API

Read outlook eml file without outlook API

This post addresses how to  extract From,To,Subject and message body content from  *.eml file. Initialy i have tried my hand in using

Outlook API but results intermittent security exception while instatntiating the object. After much exploration in the web came to know about

the COM API called Collaborative Data Object model it can be located under Add Reference in VisualStudio under COM section namely

Microsoft CDO For Windows 2000 Library.

Below the code snippet where *.eml file name will be passed in turn returns object of type CDO.Message.

protected CDO.Message ReadMessage(String emlFileName)
            CDO.Message msg = null;
                msg = new CDO.MessageClass();
                ADODB.Stream stream = new ADODB.StreamClass();
                stream.Open(Type.Missing, ADODB.ConnectModeEnum.adModeUnknown, ADODB.StreamOpenOptionsEnum.adOpenStreamUnspecified, String.Empty, String.Empty);
                msg.DataSource.OpenObject(stream, “_Stream”);
            catch (Exception ex)
            { }
            return msg;
Note:  using Outlook Express  you can save the message as *.eml file.
  1. Bluesie-Jazzie
    October 23, 2013 at 4:11 am

    There are ways around it: use CoolUtils Mail viewer and export fields in fact files, which you can save as PDF, HTML, CSV, XLS and TXT files. This is a free program!

    • December 22, 2013 at 7:30 pm

      Thanks for your comment.But those are from third party party vendors.What i have suggested is Windows built-in component.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: