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.
stream.Open(Type.Missing
stream.LoadFromFile(emlFileName);
stream.Flush();
msg.DataSource.OpenObject(stream,
“_Stream”);
msg.DataSource.Save();
}
catch
(Exception
ex)
{ }
return
msg;
}
Note: using Outlook
Express you can save the message as *.eml file.
|
Karthik RPosted Sep 18, 2020, 8:45 AM
I am using the above example. I am not able to get the embedded image content from the body part.Only I get the cid reference
SiranoPosted Mar 13, 2013, 4:45 AM
There are many libraries able to create and read .eml files on .NET Framework and Mono. One of them is Email .NET http://www.independentsoft.com
Vimal ChowdhryPosted Mar 12, 2013, 7:13 AM
Have you looked at the Chilkat Software offering for this. It is a commercial product. Here is the link for their code examples: http://www.example-code.com/csharp/emailObject.asp