/** * Send a simple message based on a Velocity template. * * @param msg * @param templateName * @param model */ public void sendMessage(SimpleMailMessage msg, String templateName, Map model) { String result = null; try { result = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, templateName, model); } catch (VelocityException e) { e.printStackTrace(); } msg.setText(result); send(msg); }
/** * Send a simple message based on a Velocity template. * * @param msg * @param templateName * @param model */ @SuppressWarnings("unchecked") public void sendMessage(PlanetsMailMessage msg, String templateName, Map model) { String result = null; try { result = PlanetsMailer.mergeTemplateIntoString(velocityEngine, templateName, model); } catch (VelocityException e) { e.printStackTrace(); } msg.setBody(result); send(msg); }
/** * Send a simple message based on a Velocity template. * * @param msg the message to populate * @param templateName the Velocity template to use (relative to classpath) * @param model a map containing key/value pairs */ @SuppressWarnings("unchecked") public void sendMessage(SimpleMailMessage msg, String templateName, Map model) { String result = null; try { result = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, templateName, "UTF-8", model); } catch (VelocityException e) { e.printStackTrace(); log.error(e.getMessage()); } msg.setText(result); send(msg); }
public SimpleMailMessage mergeSimpleMessage(String to, Map<String, Object> model) { // render text of mail from velocity template with the data String text = null; try { text = renderText(model); } catch (VelocityException e) { log.error(e); e.printStackTrace(); } // mail message setting SimpleMailMessage message = new SimpleMailMessage(); message.setSubject(getSubject()); message.setFrom(getFrom()); message.setTo(to); message.setText(text); return message; }