Sicos1977 / MSGReader

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

Removing an attachement from EML and then saving the messages, still includes deleted attachement #363

Closed sven-peeters-stitchd-be closed 1 year ago

sven-peeters-stitchd-be commented 1 year ago

I have an eml file with 3 attachements which I open, then delete the middle attachement (pos 1) and finally save the EML with a different filename. Unfortunately the result EML still contains all attachements.

var msg = MsgReader.Mime.Message.Load(new FileInfo("C:\Users\XXXX\Downloads\test.eml")); msg.Attachments.RemoveAt(1); msg.Save(new FileInfo("C:\Users\XXXX\Downloads\test_clean2.eml"));

Guessing the issue is in the Save method on the Message class where you either save it as raw (I think that's the original message) when changes are detected on attachements or reconstruct the message when no changes are detected on the attachement. I think this condition should be inverted.

Sicos1977 commented 1 year ago

Yeah you are right, the if statement should be inverted :-) ... that is what you get if you dont test it :-)

Sicos1977 commented 1 year ago

Should be fixed now