Search code examples
javaemailapache-commons-logging

Getting email client does not support HTML messages for Email through Java


I am sending email using apache-commons-logging.jar. I am able to send html email successfully, but few people are getting Your email client does not support HTML messages message in their mail. The following is the code sample -

HtmlEmail htmlEmail = new HtmlEmail();
htmlEmail.setHostName("localhost");
htmlEmail.addTo(email, "demo1@sample.com");
htmlEmail.setFrom("demo2@sample.com", "Demo2");
htmlEmail.setSubject("Subject Line");

String msg = "<html>Hi Demo1,";
msg       += "<br><br> &nbsp;&nbsp;&nbsp;&nbsp; A very warm Welcome";
msg       += "</html>";
htmlEmail.setHtmlMsg(msg);

// set the alternative message
htmlEmail.setTextMsg("Your email client does not support HTML messages");

// send the email
htmlEmail.send();

I am not understanding how to resolve this problem.

Please Gurus help me.

Thanks in advance.


Solution

  • Likely you are using Commons Email and not Commons Logging to send e-mails.

    It is expected that those who configured their e-mail client to prefer text, actually do see the text instead of HTML. Only thing what you as a sender can do is to write more meaningful plain text message.