Sicos1977 / MSGReader

C# Outlook MSG file reader without the need for Outlook
http://sicos1977.github.io/MSGReader
MIT License
475 stars 168 forks source link

Question about reading attachments from a .msg file #374

Closed trentonsnoble closed 11 months ago

trentonsnoble commented 11 months ago

Hello! I'm trying to leverage this package to load a .msg file from a drive and read its attachments using this code. The .msg appears to load correctly (I tried removing it from my drive and got an exception, so i think its loading properly), but there are no attachments and my for loop does not run. Am I doing something wrong or is this a bug?

var msg = MsgReader.Mime.Message.Load(new FileInfo(msgFilepath));
foreach(var attachment in msg.Attachments) { fileList.Add(attachment.FileName); }

trentonsnoble commented 11 months ago

I figured it out.

I should be using this code. Beware, images in the .msg will be loaded as attachments as well. I'll close this issue.

new MsgReader.Outlook.Storage.Message(msgFile);