Hi,
I am not sure that this thread is posted in the right forum, anyway here is my problem :
I try to send a message in HTML format. Here is the code :
and the message is the following :
according to what I found on internet, the method MimeMessageHelper.setText(message,true); specifies that the message is sent in HTML format ( second argument is boolean "true" saying it is a HTML message ).
But I don't get the message in HTML format. Anyone can help me ? thank you in advance
I am not sure that this thread is posted in the right forum, anyway here is my problem :
I try to send a message in HTML format. Here is the code :
Code:
public void sendMessage(String subject, String message, String to, String cc, String bcc) throws MessagingException { MimeMessage mimeMessage = mailSender.createMimeMessage(); MimeMessageHelper mimeMessageHelper = new MimeMessageHelper(mimeMessage, true, "UTF-8"); if(to!=null && !to.equals("")){ mimeMessageHelper.setTo(to); } if(cc!=null && !cc.equals("")){ mimeMessageHelper.setCc(cc); } if(bcc!=null && !bcc.equals("")){ mimeMessageHelper.setBcc(bcc); } mimeMessageHelper.setSubject(subject); mimeMessageHelper.setText(message,true); mimeMessageHelper.setFrom(from); logger.info("host = "+mailSender.getHost()); logger.info("Port = "+mailSender.getPort()); //logger.info("UserName = "+mailSender.getUsername()); //logger.info("Password = "+mailSender.getPassword()); mailSender.send(mimeMessage); }
and the message is the following :
Code:
String message = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"<URL>">"+ "<htmlxmlns=\"<URL>\"><head><head/><body>" +messageSource.getMessage("messagetosend.part1", null, Locale.ENGLISH)+ user.getFirstName()+" "+ user.getLastName()+"<br/>" + messageSource.getMessage("messagetosend.part2", null, Locale.ENGLISH)+<br/>" + messageSource.getMessage("messagetosend.part3", null, Locale.ENGLISH)+ newPassword+<br/>" + messageSource.getMessage("messagetosend.part4", null, Locale.ENGLISH)+<br/>" + messageSource.getMessage("messagetosend.part5", null, Locale.ENGLISH)+<br/>" + messageSource.getMessage("homepage.internet.address", null, Locale.ENGLISH)+"</body></html>";
according to what I found on internet, the method MimeMessageHelper.setText(message,true); specifies that the message is sent in HTML format ( second argument is boolean "true" saying it is a HTML message ).
But I don't get the message in HTML format. Anyone can help me ? thank you in advance
Comment