Free Support Forum -

Creating HTMLBody from RTF-File

Hello Aspose-Team,

we use the Aspose.Network-Library to read and send e-mails.

In our project we have now an additional requirement: we must create a HTMLBody from a RTF-File. Is it possible to convert the rtf text to HTML with the Network-Library? Or is it possible to create an msg from the rtf file?

Best regards

Hi Ralf,

I am sorry, currently text or Html body can be used to create message files, using Aspose.Network.

Although, MapiMessage class has BodyRtf property, but it has only get accessor. It cannot be set.

We will do some analysis to create an msg file from Rtf.

Currently, it is possible with the help of Aspose.Words library. The sample code is below:

// use Aspose.Words to convert rtf to mhtml
Document rtfDoc = new Document(@“test.rtf”, LoadFormat.Rtf, “”);
MemoryStream stream = new MemoryStream();
rtfDoc.Save(stream, SaveFormat.Mhtml);
stream.Position = 0;

// load mhtml stream in MailMessage to create or send message
MailMessage msg = MailMessage.Load(stream, MessageFormat.Mht);
msg.Save(“test.msg”, MailMessageSaveType.OutlookMessageFormat);