I'm writing an application that monitors an Exchange mailbox using EWS. It saves the attachments of the incoming mails to a network folder.

These files are then used by a 3d party application.

Now I've been asked if it is possible to not only save the attachments but the entire e-mail with attachments still included so it can be opened in Outlook. (no other mailclients need to be supported).

The Exchange server is Exchange 2010 and the application is being written in C# Can this be done using EWS? Or is my only solution to use Interop.Outlook to create a .msg file?

有帮助吗?

解决方案

Which Outlook version are you using? Outlook 2010 can open .EML files, which is the "native" storage format for mails (RFC 2822). In this case, you can use the EWS Webservices (or EWS Managed API) to download the MIME content.

In any other cases, have a look at Outlook Redemption (http://www.dimastr.com/redemption/). It can save items as .msg file and can be used from C#.

其他提示

ExchangeService exchangeService = ...
EmailMessage mailMessage = ...

var propertySet = new PropertySet(BasePropertySet.FirstClassProperties, ItemSchema.MimeContent, EmailMessageSchema.IsRead);

exchangeService.LoadPropertiesForItems(mailMessage, propertySet);

File.WriteBytes("filename.eml", mailMessage.MimeContent.Content);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top