4

I'm working with the EWS Managed API 2.0. At this moment I can save EmailMessages to my harddrive as *.eml files. However I can't open them correctly to show the content.

How can an EmailMessage (.eml) be saved as an .html, .doc or .txt file directly?

juFo
  • 17,849
  • 10
  • 105
  • 142
  • When you say you can't open them correctly to show the content, what do you mean? Are you trying to view them in outlook (or some other client) interactively, or do you mean programmatically to interrogate their content? – sasfrog Apr 29 '13 at 22:24
  • 1
    figured out it is rather complex to display EML because of MIME etc... – juFo Apr 30 '13 at 14:42

1 Answers1

6

Use following code if you want to save it as .eml

message.Load(new PropertySet(ItemSchema.MimeContent));
MimeContent mimcon = message.MimeContent;
FileStream fStream = new FileStream("c:\test.eml", FileMode.Create);
fStream.Write(mimcon.Content, 0, mimcon.Content.Length);
fStream.Close();

For msg file look at following link:

http://msdn.microsoft.com/en-us/library/cc463912%28EXCHG.80%29.aspx

After saving it as .eml file you can look at following post for parsing it:

Recommendations on parsing .eml files in C#

Hope its helpful.

Community
  • 1
  • 1
Freelancer
  • 9,008
  • 7
  • 42
  • 81
  • I can save them already as .eml (see original post). I'm going to wait for another reply before I can accept this. – juFo Apr 05 '13 at 07:45
  • Freelancer, thanks that edited link. Still not happy to see that old COM dll there but maybe there is no other better solution...? – juFo Apr 05 '13 at 09:08