I am using TinyMCE in my website to get some data
I am storing the data in the MySQL database .. I am storing the HTML generated from the RTE to the database
It works fine when I have to display the data on a browser and everything is neatly formatted
However When I try to send that via email … I get HTML in the email (and that too escaped)
Emailer code (just a start) is as follows:
public static void sendMail(String to, String from, String subject, String content)
throws Exception
{
if(!ScribeBookConstants.isEmailEnabled())
return;
//String host = "s155.eatj.com";
String host = ScribeBookConstants.getEmailHost();
Properties props = new Properties();
props.put("mail.smtp.host", host);
props.put("mail.smtp.auth", "true");
SMTPAuthenticator auth = new SMTPAuthenticator();
Session session = Session.getDefaultInstance(props, auth);
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(from));
InternetAddress[] address = {new InternetAddress(to)};
msg.setRecipients(Message.RecipientType.TO, address);
msg.setSubject(subject);
msg.setSentDate(new Date());
msg.setText(content);
Transport.send(msg);
}
I tried to send an email to a Gmail account … and get escaped HTML in the message text
Actually found the solution
I just had to set the content type to “text/html”