List of usage examples for javax.mail Message setDataHandler
public void setDataHandler(DataHandler dh) throws MessagingException;
From source file:org.sventon.repository.observer.MailNotifier.java
/** * @param logEntry Log entry/*ww w .ja v a2s . c o m*/ * @param repositoryName Name * @param mailTemplate Template * @return Message * @throws MessagingException If a message exception occurs. * @throws IOException if a IO exception occurs while creating the data source. */ private Message createMessage(final SVNLogEntry logEntry, RepositoryName repositoryName, String mailTemplate) throws MessagingException, IOException { final Message msg = new MimeMessage(session); msg.setFrom(new InternetAddress(from)); msg.setRecipients(Message.RecipientType.BCC, receivers.toArray(new InternetAddress[receivers.size()])); msg.setSubject(formatSubject(subject, logEntry.getRevision(), repositoryName)); msg.setDataHandler( new DataHandler(new ByteArrayDataSource(HTMLCreator.createRevisionDetailBody(mailTemplate, logEntry, baseUrl, repositoryName, dateFormat, null), "text/html"))); msg.setHeader("X-Mailer", "sventon"); msg.setSentDate(new Date()); return msg; }