Hello,
I am trying to send html in email but instead of html I just get plain text.
I am trying to send this string
<html><body><p>Hello</p></body></html>
I have tried to set content of the email to "text/html" as well as to "text/html; charset=\"ISO-8859-1\"".
I am viewing this email in Outlook 2007
Here is the method which sends the email.
public void sendMail(String fromEmail, String toEmail, String subject, String messageBody)
throws MessagingException {
Properties props = System.getProperties();
props.put("mail.smtp.host", host);
Session session = Session.getDefaultInstance(props, null);
MimeMessage message = new MimeMessage(session);
message.setContent(messageBody.toString(), "text/html");
// message.setContent(messageBody, "text/html; charset=\"ISO-8859-1\"");
message.setFrom(new InternetAddress(fromEmail));
message.addRecipient(Message.RecipientType.TO,
new InternetAddress(toEmail));
message.setSubject(subject);
message.setText(messageBody);
Transport.send(message);
}