The e-mail is being sent using Spring and java mail sender.
Is their anyway I can use a normal jsp view and jstl tags - I don't want to learn another bunch of tags/syntax ?
Currently my code looks like this :
StringBuffer content = new StringBuffer();
Configuration configuration = freeMarkerConfigurer.getConfiguration();
String templateName = "vslEmail.ftl";
Map<String, String> templateVars = new HashMap<String, String>();
templateVars.put("firstName", "john");
templateVars.put("surname", "doe");
try {
content.append(FreeMarkerTemplateUtils.processTemplateIntoString(configuration.getTemplate(ftlName), tempalteVars));
}
catch (Exception e) {
// handle
}
// content.append("<br>Test data");
sendMime(defaultEmailAddress, subject, content.toString());
I would just prefer to reference a jsp instead of the ftl ?
You can explicite render a jsp, but you need a Request Object!
See also this StackOverflow Answer (and the other answers to that question). It shows an example to create a (fake) response object, that allows you to process the created html.
You could always fire off a request to a JSP sitting on your own web server, slurp up the response, and drop it into your email. It's a little hacky, and care must be taken to make sure you don't open up those pages to the outside world, but it would work.