Reputation: 18567
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?
Upvotes: 4
Views: 5629
Reputation: 9074
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.
Upvotes: 6