I’m creating a windows application and want to send an email using the SmtpClient composed in a Rich Text Box. However my two options in the MailMessage class are HtmlBody and TextBody, Is it capable of converting the Rich Text Format to HTML or sending the email in RTF?
Hi Steven,
Thank you for considering Aspose.Email and we are sorry for a delayed response.
The MailMessage class doesn’t have the capability of converting the Rich Text Format to HTML automatically. However, you can load the contents of the RTF in MapiMessage and interpret it to MailMessage object, which will automatically convert the RTF body to HTML as shown in the following code sample and email can be sent to preserve the formatting.
Sample Code:
string dir = "EMAIL_513747\\";
string path = @"test.rtf";
// Get the contents of the RTF file.
string rtfText = System.IO.File.ReadAllText(dir + path);
// Display the RTF text. This should look like the contents of your file.
MapiMessage mapi = new MapiMessage();
mapi.BodyRtf = rtfText;
MailMessageInterpretor mi = MailMessageInterpretorFactory.Instance.GetIntepretor(mapi.MessageClass);
MailMessage mailMsg = mi.Interpret(mapi);
// Save or send the MailMessage
mailMsg.Save(dir + "newHtml.msg", MailMessageSaveType.OutlookMessageFormat);
RTFMessage = MapiMessage.FromMailMessage(msg);
RTFMessage.BodyRtf = rtbMessage.Rtf;
MailMessageInterpretor mi = MailMessageInterpretorFactory.Instance.GetIntepretor(RTFMessage.MessageClass);
MailMessage mailMsg = mi.Interpret(RTFMessage);
//Create an instance of SmtpClient class
SmtpClient client = GetSmtpClient();
try
{
// Send the email
client.Send(mailMsg);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
--------------------------------------------------------------------------------------------------

Hi Steven,
MemoryStream mhtmlStream = new MemoryStream();
wordDocument.Save(mhtmlStream, Aspose.Words.SaveFormat.Mhtml);
// Load the MHTML in MailMessage
mhtmlStream.Position = 0;
MailMessage message = MailMessage.Load(mhtmlStream, MessageFormat.Mht);
message.Subject = “Sending Invoice in Email”;
message.From = “sender@gmail.com”;
message.To = “recipient@gmail.com”;
// Save the message in MSG format to disk
message.Save(“test.msg”, MailMessageSaveType.OutlookMessageFormat);