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

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

Introduction

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

Prototype

public Email addTo(final String email) throws EmailException 

Source Link

Document

Add a recipient TO to the email.

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());//from w  ww  . ja v  a2s .  c om
    //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);
}