List of usage examples for org.springframework.mail.javamail MimeMessageHelper MimeMessageHelper
public MimeMessageHelper(MimeMessage mimeMessage, int multipartMode) throws MessagingException
From source file:ubic.gemma.util.MailEngineImpl.java
/** * Convenience method for sending messages with attachments. * /* w ww. j a v a 2 s.c o m*/ * @param emailAddresses * @param resource to be attached * @param bodyText * @param subject * @param attachmentName * @throws MessagingException * @author Ben Gill */ @Override public void sendMessage(String[] emailAddresses, ClassPathResource resource, String bodyText, String subject, String attachmentName) throws MessagingException { MimeMessage message = ((JavaMailSenderImpl) mailSender).createMimeMessage(); // use the true flag to indicate you need a multipart message MimeMessageHelper helper = new MimeMessageHelper(message, true); helper.setTo(emailAddresses); helper.setText(bodyText); helper.setSubject(subject); helper.addAttachment(attachmentName, resource); ((JavaMailSenderImpl) mailSender).send(message); }