Free Support Forum -

Need to set RTF body for mails

Am loading one EML which is having HTML body into mail message.
MailMessage f_Objmailmessage = null;

f_Objmailmessage = MailMessage.Load(“eml path”, new EmlLoadOptions());

It is loading properly and setting Body type as HTML.
I need to overwrite the body content with some RTF text and tried using the below line:
MapiMessage f_mapimessage = null;
f_mapimessage = MapiMessage.FromMailMessage(f_Objmailmessage, MapiConversionOptions.UnicodeFormat);
p_Messageobj.SetBodyContent(“RTFBody contents”, BodyContentType.Rtf);

But it is not changing the body format from HTML to RTF.

Is there any option to assign body format manually ?


Thank you for writing to Aspose support team.

You need to set proper rtf body instead of plain string. Please give a try to the following sample code and share the feedback.

MapiMessage mapi = new MapiMessage("", "", "Subject", "Body", OutlookMessageFormat.Unicode);
var rtfText = File.ReadAllText(@"Rtf.txt");
`mapi.SetBodyContent(rtfText, BodyContentType.Rtf);`
mapi.Save(@"Rtf.msg", MsgSaveOptions.DefaultMsgUnicode); (8.1 KB)