Wrong sent date saved while saving the message as .msg from mbox

Sample code:
var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);
var mBox = MboxStorageReader.CreateReader(fs, new MboxLoadOptions()
{
LeaveOpen = true,
PreferredTextEncoding = Encoding.UTF8
});
Aspose.Email.MailMessage msg = mBox.ExtractMessage(“AAAAAMUAAQCEAAAAAAAAAA==”, new Aspose.Email.EmlLoadOptions()
{
PreferredTextEncoding = Encoding.UTF8
});
msg.Save(@“message.msg”, Aspose.Email.SaveOptions.DefaultMsg); // Save wrong sent date
msg.Save(@“message.eml”, Aspose.Email.SaveOptions.DefaultEml); // Save Correct sent date

Note: If we save the file as .eml then sent date correctly update.
image.png (55.9 KB)

Required Files:
MBox.zip (270.8 KB)

Please provide solution as soon as possible

@hemalp
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): EMAILNET-41342

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

Hi @hemalp

To fix this issue you can use next code:

            MsgSaveOptions msgOptions = SaveOptions.DefaultMsg;
            msgOptions.PreserveOriginalDates = true;
            msg.Save(@“message.msg”, msgOptions);

Note: since Aspose.Email 24.5 the setting PreserveOriginalDates will be set to true by default.

Hello @alexander.pavlov

Still your given solution is not working, Lastmodification date and creation date is not proper, please find below attachment and sample code.

Note: you can Also use below EntryId: AAAAAMUAAQAegloCAAAAAA== or AAAAAMUAAQB0rVoCAAAAAA==

SampleCode:

var fs = new FileStream(path, FileMode.Open, FileAccess.Read);
var mBox = MboxStorageReader.CreateReader(fs, new MboxLoadOptions()
{
    LeaveOpen = true,
    PreferredTextEncoding = Encoding.UTF8
});
Aspose.Email.MailMessage msg = mBox.ExtractMessage("AAAAAMUAAQD0ZloCAAAAAA==", new Aspose.Email.EmlLoadOptions()
{
    PreferredTextEncoding = Encoding.UTF8
});
MemoryStream ms = new MemoryStream();
MsgSaveOptions msgOptions = SaveOptions.DefaultMsg;
msgOptions.PreserveOriginalDates = true;
msg.Save(ms, msgOptions);

var mapiMsg = MapiMessage.Load(ms);
DateTime? last = mapiMsg.GetPropertyDateTime(MapiPropertyTag.PR_LAST_MODIFICATION_TIME);
DateTime? create = mapiMsg.GetPropertyDateTime(MapiPropertyTag.PR_CREATION_TIME);

SampleFile:
SampleFile_MBOX.zip (3.8 MB)

Hi @hemalp
Thank you for collaboration.
Let me check it.

Hi @hemalp
This issue was fixed. Fix will be available in 24.05 version.

Hello @alexander.pavlov

while we are using Aspose.Email version 24.5 getting “null” value of Lastmodification date and creation date.

Hi @hemalp
This is expected behavior. The MIME content in the mbox file does not contain the lastmodified and created date, so if you set PreserveOriginalDates=true then it will not be set when saving as msg.