Example usage for org.apache.commons.mail Email addBcc

List of usage examples for org.apache.commons.mail Email addBcc

Introduction

In this page you can find the example usage for org.apache.commons.mail Email addBcc.

Prototype

public Email addBcc(final String email, final String name) throws EmailException 

Source Link

Document

Add a blind BCC recipient to the email using the specified address and the specified personal name.

Usage

From source file:org.ploin.pmf.impl.MailSender.java

private void setMailProperties(Email email, MailConfig mailConfig) throws MailFactoryException {
    try {/*from   w w w  .  j a v  a  2  s .  c o  m*/
        email.setSubject(mailConfig.getSubject());

        for (Recipient toRecipient : mailConfig.getToRecipients()) {
            if (toRecipient.getName() != null) {
                email.addTo(toRecipient.getEmail(), toRecipient.getName());
            } else {
                email.addTo(toRecipient.getEmail());
            }
        }

        if (!mailConfig.isCcRecipientEmpty()) {
            for (Recipient ccRecipient : mailConfig.getCcRecipients()) {
                if (ccRecipient.getName() != null) {
                    email.addCc(ccRecipient.getEmail(), ccRecipient.getName());
                } else {
                    email.addCc(ccRecipient.getEmail());
                }
            }
        }

        if (!mailConfig.isBccRecipientEmpty()) {
            for (Recipient bccRecipient : mailConfig.getBccRecipients()) {
                if (bccRecipient.getName() != null) {
                    email.addBcc(bccRecipient.getEmail(), bccRecipient.getName());
                } else {
                    email.addBcc(bccRecipient.getEmail());
                }
            }
        }
    } catch (Exception e) {
        throw new MailFactoryException(e);
    }
}