문제

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