Pergunta

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?

Foi útil?

Solução

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top