Create/Open existing msg from path to new Outlook.MailItem in c#

喜夏-厌秋 提交于 2019-12-06 05:35:37

To open an item in outlook try:

var email = (Outlook.MailItem)app.Session.OpenSharedItem(fl)

From there, you can access the Attachments property and Body property as well.

Also, as I mentioned in my comment if the Regex.IsMatch is to determing the file extension, use Path.GetExtension() instead

I used this NuGet package: https://www.nuget.org/packages/MSGReader/

Seems to work fine. I prefer it to the MS OutlookApi library because it doesn't require Outlook to be installed.

I appreciate that it won't create instances of MailItem, as you have asked for in your question - but it will enable you to extract save the individual attachments and the body...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!