Save from PST/OST to RFC822 .eml stream, instead of .msg

Hello,
This will perfectly save a message by id to msg stream, anyway to save it in eml format instead?

Aspose.Email.Storage.Pst.PersonalStorage.FromFile(pst file).SaveMessageToStream(EntryIdString, blahMemoryStream)

@australian.dev.nerds

Please refer to the following article to achieve your requirement.
How to Convert PST to EML Using C#

Thanks, the provided sample requires using EnumerateMapiMessages instead of EnumerateMessages.
The problem is lack of EntryIdString in EnumerateMapiMessages.
There are 2 other properties: InternetMessageId and ItemID, which one is the message unique ID inside the pst/ost?

@australian.dev.nerds

A ticket has been logged for your requirement as EMAILNET-40685. We will inform you via this forum thread once there is an update available on it.

@australian.dev.nerds

Regarding EMAILNET-40685, please use the following code example to save messages in .eml format.

using var pst = PersonalStorage.FromFile(@"Outlook.pst");
var inboxFolder = pst.GetPredefinedFolder(StandardIpmFolder.Inbox);

// read messages from Inbox
foreach (var msg in inboxFolder.EnumerateMapiMessages())
{
    await using var stream = File.OpenWrite(emlFileName);

    // save message to stream in eml format
    msg.ToMailMessage(new MailConversionOptions{}).Save(stream);
}

To store the entry id there is an PidTagEntryId MAPI property. We are not populating this property when reading messages from PST. It is not necessary to have this property because message is no longer a storage item after extracting.

If you need to save an entryId for something, use the following code example.

using var pst = PersonalStorage.FromFile(@"Outlook.pst");
var inboxFolder = pst.GetPredefinedFolder(StandardIpmFolder.Inbox);

// read messages from Inbox
foreach (var entryId in inboxFolder.EnumerateMessagesEntryId())
{
    var msg = pst.ExtractMessage(entryId);

    // set the EntryId to msg 
    msg.SetProperty(KnownPropertyList.EntryId, Convert.FromBase64String(entryId));

    // read the EntryId from msg
    var property = msg.Properties[KnownPropertyList.EntryId.Tag];

    if (property != null)
    {
        Console.WriteLine($"EntryId: {Convert.ToBase64String(property.Data)}");
    }
}