I have a freeMarker template .ftl file that has html + css styling code. This template gets the dynamic model data to replace the place holders during runtime. And after freeMarker processing I send that string content as email body but the received email shows raw html + css code which is unexpected, it suppose to show the actual content with css styling applied to the content rather than showing the raw html with css code in the received email body.
Dynamic data gets replaced appropriatly.
sample code like,
import freemarker.template.Configuration;
@Autowired
private Configuration freeMarkerConfig;
Map<String,String> model = new HashMap<>();
model.put("name", fName);
model.put("address", fAddress);
configuration.setClassForTemplateLoading(this.getClass(), "/templates");
final Template template = freeMarkerConfig.getTemplate("testEmail.ftl");
final String emailBodyInHtml = FreeMarkerTemplateUtils.processTemplateIntoString(template, model);
*** now when we send emailBodyInHtml as email body to email component then the received email displays content string of emailBodyInHtml (which is raw html + css style code), actual email content should be prety printed email body with css styling applied to the content.
My email client is MS Outlook
Mahantesh Halakatti is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.