There is a bug in Aspose.Email 19.6. It does not exist in 19.5.
Aspose.Email 19.6 seems to generate a corrupted PST file in some cases. Here is how to reproduce:
var files = Directory.GetFiles(@"c:\messages", "*.msg");
using (var storage2 = PersonalStorage.Create(@"C:\result.pst", FileFormatVersion.Unicode))
var folder2 = storage2.RootFolder;
var msgs = files.Take(300).Select(file => MapiMessage.FromStream(new MemoryStream(File.ReadAllBytes(file)))).ToList();
var msgs2 = files.Skip(300).Select(file => MapiMessage.FromStream(new MemoryStream(File.ReadAllBytes(file)))).ToList();
The messages folder contains 509 MSG files. These files are attached. Because it is a big file, please download from: https://www.zevainc.com/download/messages.zip
The bug does not happen if we use AddMessage instead of AddMessages.
The bug does not happen if we use AddMessages a single time. That is if we add the 509 at once.
The bug happens if we add 300 messages and then add the remaining 209 messages.
What is the problem?
The generate PST file has issues. Here is how to see the problem:
Once the result.pst file is generated, add it to outlook as a data file. Then use MFCMAPI (https://github.com/stephenegriffin/mfcmapi) to open the message with subject “RTF/HTML Email with various attachments”. Once you open the message, try to change a property (e.g. PR_SUBJECT) and then save changes. You will get a MAPI_E_OBJECT_DELETED error.