I'm sending an email with the JavaMailSender with html in the body like this:
String html = "<h2>RFC INVALIDOS en México:</h2>"+
"<h4>Se adjunta el siguiente listado de RFC inválidos al día de la fecha.</h4>" +
"<h3>Saludos!!!</h3>";
MimeMessageHelper helper = return new MimeMessageHelper(mimeMessage, true); // some helper
helper.setSubject(message.getSubject());
helper.setText(html, true);
Look at the vowels, (á, é, í) in "México", "inválidos" and "día"
and the mail is sended clipped, telling me is something more to see:
Notice the part:
...
[Mensaje recortado] Ver todo el mensaje
But if I send it without quoting the vowels:
String html = "<h2>RFC INVALIDOS en Mexico:</h2>"+
"<h4>Se adjunta el siguiente listado de RFC invalidos al dia de la fecha.</h4>" +
"<h3>Saludos!!!</h3>";
**look at the vowels **Look at the vowels, (a, e, i), in "mexico", "invalidos" and "dia"****
The mail is correctly and perfectly sent.
Any clues?
MimeMessageHelper message = new MimeMessageHelper(mimeMessage, true, "UTF-8");
This is found here: https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/mail/javamail/MimeMessageHelper.html
It is implemented in their example as an abstract object definition:
mailSender.send(new MimeMessagePreparator() {
public void prepare(MimeMessage mimeMessage) throws MessagingException {
MimeMessageHelper message = new MimeMessageHelper(mimeMessage, true, "UTF-8"); // Here is where it seems the encoding can be set, through this helper class.
//...
I've also just found something cool now looking at the api. It may even be easier for you, if, you can make your signature a small kb image resource, and send it that way. This makes you not have to worry about UTF-8 in this scenario.
message.addInline("signature.png", new ClassPathResource("img/signature.png"));
Anyway, hope this helps. Let me know if I can try to explain it better for you. (UTF-8)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With