Hi, Aspose team.
Scenario: My app processes EML messages. Some of them have TNEF format (with “application/ms-tnef” content type and winmail.dat attachment). App reads winmail.dat attachment using MapiMessage.LoadFromTnef message.
If TNEF message contains embedded message, app saves it to file (MSG format is used), processes MSG file in some way, then replaces embedded message content with the content of the processed MSG file.
Then app saves MapiMessage back to TNEF and replaces content of winmail.dat attachment.
Issue: HTML body of the embedded message is lost. Outlook show plain text body. see issue.png (59.7 KB)
Sample EML: sample.zip (876.4 KB)
using (var mailMessage = MailMessage.Load("sample for Aspose.eml",
new EmlLoadOptions
{
PreserveTnefAttachments = true,
}))
{
using (var newTnefStream = new MemoryStream())
{
using (var mapiFromTnef = MapiMessage.LoadFromTnef(mailMessage.Attachments[0].ContentStream))
{
// for the sake of simplicity I reassign
// content of the embedded message
mapiFromTnef.Attachments[0]
.SetProperty(new MapiProperty(MapiPropertyTag.PR_ATTACH_DATA_OBJ,
mapiFromTnef.Attachments[0].ObjectData.Data));
// Save MAPI message back to TNEF attachment
mapiFromTnef.SaveAsTnef(newTnefStream);
}
// update content of the winmail.dat attachment
newTnefStream.Position = 0;
mailMessage.Attachments[0].ContentStream = newTnefStream;
mailMessage.Save("resaved.eml", new EmlSaveOptions(MailMessageSaveType.EmlFormat));
}
}
Thanks.