use of org.springframework.mail.javamail.MimeMessageHelper in project ArachneCentralAPI by OHDSI.
the class ArachneMailSender method send.
public void send(ArachneMailMessage mailMessage) {
MimeMessage message = mailSender.createMimeMessage();
MimeMessageHelper helper;
try {
helper = new MimeMessageHelper(message, true);
helper.setSubject(mailMessage.getSubject());
helper.setFrom(from, mailMessage.getFromPersonal());
helper.setTo(mailMessage.getUser().getEmail());
helper.setText(buildContent(mailMessage.getTemplate(), mailMessage.getParameters()), true);
mailSender.send(message);
} catch (MailConnectException e) {
LOG.error(e.getMessage(), e);
throw new MailSendException(e.getMessage());
} catch (MessagingException | UnsupportedEncodingException ex) {
LOG.error(ex.getMessage(), ex);
} catch (MailSendException e) {
LOG.error(e.getMessage(), e);
throw new MailSendException("Failed to send e-mail. Please, contact to the administrator.");
}
}
Aggregations