Scenario: Aspose.Email.dll 4.8.0.0. EML message in TNEF format (file attached). Message contains 3 regular attachments (DOCX, XLSM, JPG) and 1 inline image. I remove first attachment (the same if you remove other attachment) using RemoveAt or Remove method and save to the file with PreserveTnefAttachments flag.
Thanks,
Issue: ArgumentOutOfRangeException is thrown.
Stack trace:
at System.Collections.Generic.List`1.get_Item(Int32 index)
at Aspose.Email.Mail.TnefAttachment. (IList`1 )
at Aspose.Email.Mail.MailMessage. ()
at Aspose.Email.Mail.MailMessage.SaveAsTnef(Stream )
at Aspose.Email.Mail.MailMessage.Save(Stream stream, SaveOptions options)
at Aspose.Email.Mail.MailMessage.Save(String fileName, SaveOptions options)
at TestConsoleApplication.Program.Main(String[] args)
Code:
var m = MailMessage.Load(@"1680.eml", MailMessageLoadOptions.DefaultEml);
// remove DOCX file
m.Attachments.RemoveAt(0);
var sop = SaveOptions.DefaultEml;
sop.FileCompatibilityMode = FileCompatibilityMode.PreserveTnefAttachments;
//m.Attachments.Add(new Attachment("..."));
m.Save(@"1680-saved.eml", sop);
Findings: If you uncomment line in the code snippet and specify path to any existing file, then no exception is thrown during saving message. BUT when you open saved message in Outlook
- has 2 XLSM files instead of 1;
- has no image JPG attachment.
Please investigate this ASAP. This is very critical bug.
Alex Shloma