Example usage for org.apache.commons.mail HtmlEmail setHtmlMsg

List of usage examples for org.apache.commons.mail HtmlEmail setHtmlMsg

Introduction

In this page you can find the example usage for org.apache.commons.mail HtmlEmail setHtmlMsg.

Prototype

public HtmlEmail setHtmlMsg(final String aHtml) throws EmailException 

Source Link

Document

Set the HTML content.

Usage

From source file:velo.tools.EmailSender.java

public void addHtmlEmail(String fromAddress, Collection<String> recipient, String subject, String body)
        throws EmailException {
    HtmlEmail email = new HtmlEmail();
    email.setHostName(getHostName());// w ww  .  jav  a2s.co  m
    //email.addTo("jdoe@somewhere.org", "John Doe");
    //email.addTo(recipient,recipient);
    email.setFrom(fromAddress, fromAddress);
    email.setSubject(subject);
    email.setHtmlMsg(body);
    for (String currRec : recipient) {
        email.addTo(currRec);
    }

    email.setCharset("UTF-8");

    log.debug("Adding a new message with subject '" + subject + "', from: '" + fromAddress + "', to: '"
            + recipient + "' to the queue...");
    log.debug("Email server parameters - SMTP host: " + getHostName());
    emails.add(email);
}