Set rtf content to email body

Hi,

I have an RTF file and I need to send an email by setting the content of rtf to message body.
the message body should be same as RTF with colors and table format and images.

i am extracting the rtf text and passing to body content “rtf text” but the message is not going in a format.

mapiMsg.SetBodyContent("", BodyContentType.Rtf);

MailMessage eml = msg.ToMailMessage(new MailConversionOptions());

Can you please let me know the exact way to do it in JAVA. is there any direct method to do it. if not tell me the process.

or Also tell me how can i convert rtf file to html which includes embedded images and table. So that i can set it to SetHtmlBody() method.

Don’t worry about the above post. i figured it out.
This code worked for me but images are not displaying in the email

MapiMessage mapi = new MapiMessage();

	SmtpClient client = new SmtpClient("user name", port, "username",
			"password");

	client.setSecurityOptions(SecurityOptions.Auto);

	Document doc = new Document("rtf path ");

	MailMessage eml = mapi.toMailMessage(new MailConversionOptions());

	eml.setFrom(new MailAddress("to@domain"));

	eml.getTo().addMailAddress(new MailAddress("from@domain"));

	eml.setHtmlBody(doc.toString(SaveFormat.HTML));

	client.send(eml);

Please tell me how can i display the images.

Thanks for your help.

@kishanaasa,

Please share your sample input file with us for further investigation a team our end.

When I try to upload RTF file in the reply block it is throwing an error with the unsupported file type, it is only allowing me to upload (jpg, jpeg, png, gif, zip, pdf) . So, any RTF file with an image will work for me.
i tried some of sample RTF file with images available on google. Even those are not showing up on my email body. Can you please tell me what to do now.

@kishanaasa,

In order to set the html to mail message with image, the image needs to be part of html as Base64 encoded. Please try the following code sample at your end.

Sample Code

Aspose.Words.Saving.HtmlSaveOptions options = new Aspose.Words.Saving.HtmlSaveOptions();
options.ExportImagesAsBase64 = true;
options.SaveFormat = SaveFormat.Html;

Document doc = new Document("doc with image.rtf");
doc.Save("doc with image.html", options);

MailMessage eml = MailMessage.Load("doc with image.html", new Aspose.Email.HtmlLoadOptions());

eml.From = (new MailAddress("username@gmail.com"));
eml.To = "to@gmail.com";

SmtpClient client = new SmtpClient("smtp.gmail.com", 587, "username", "password");

client.Send(eml);