0

When you sent an email with html the email has inside:

<html> = 09
= 09 = 09 <! - NAME: 1 COLUMN ->
= 09 = 09 <! - [if gte mso 15]>
= 09 = 09 <xml>
= 09 = 09 = 09 <or: OfficeDocumentSettings>
= 09 = 09 = 09 </ o: OfficeDocumentSettings>
= 09 = 09 </ xml>
= 09 = 09 <! [Endif] ->
= 09 = 09 <meta charset = 3D "UTF-8">
        <meta http-equiv = 3D "X-UA-Compatible" content = 3D "IE = 3Dedge">
        <meta name = 3D "viewport" content = 3D "width = 3Ddevice-width, initial-sc =
ale = 3D1 ">

the = 09 = 09 and = 3D cause the email body to not work properly. causing that in some buttons that I have in html the parameters do not work

MimeMessage mail = mailSender.createMimeMessage();
MimeMultipart multi = new MimeMultipart();
MimeBodyPart textPart = new MimeBodyPart();
MimeBodyPart textHtml = new MimeBodyPart();

if (html.isEmpty()) {
  textPart.setText(text, "utf-8");
  multi.addBodyPart(textPart);
} else {                     
  textHtml.setContent(MimeUtility.decodeText(html), "text/html");
  textHtml.setHeader("Content-type", "text/HTML");

  multi.addBodyPart(textHtml);
}

mail.setContent(multi);
mail.setSubject(subject);
mail.setFrom(from);
mail.setRecipients(Message.RecipientType.TO, to[0].toString());
mail.saveChanges();
this.mailSender.send(mail);

Please help!

  • If you are sending a dynamic html then it may not work, depends or application service provider and browser. Cant you create it statically before sending it ? How are you trying to send it and where? – Raghuveer Oct 23 '18 at 08:51
  • Yes, the mail is always the same, I send it to myself and it is sent through an SMTP server – Jose Gimeno Oct 23 '18 at 08:57
  • if you are using some kind of javascript for dynamic things , then it will not work , you need to create static html page first and then email it and if you have images then content type as text/html will not work , you need to do base 64 encoding and send encoded value of an image in html , then it will get viewed – Monis Majeed Oct 23 '18 at 08:57
  • so is it through gmail or some service provider ? or your own SMTP server ? What are the thing that are failing (not clear in your email). As @MonisMajeed said try and encode your whole page. – Raghuveer Oct 23 '18 at 08:59
  • How can I encrypt the email to 64? @MonisMajeed – Jose Gimeno Oct 23 '18 at 09:01
  • you can do by online https://www.base64decode.org/ or if using java check https://dzone.com/articles/base64-encoding-java-8 – Monis Majeed Oct 23 '18 at 09:02
  • The SMTP server is typical of the company. The problem is that I have a button to accept: – Jose Gimeno Oct 23 '18 at 09:06
  • I'm going to try it @MonisMajeed – Jose Gimeno Oct 23 '18 at 09:06
  • I have already modified the mail to base64 but how do I do it so that the mail does not arrive encrypted? – Jose Gimeno Oct 23 '18 at 09:16
  • The "=09" is the quoted-printable encoding of the message, the receiving mailer will decode it. When you set the content of the message you're calling MimeUtility,decodeText, why? That should not be needed. Try getting rid of that and if it still doesn't work post the complete MIME content of the message. – Bill Shannon Nov 02 '18 at 21:20

0 Answers0