Example usage for com.amazonaws.services.simpleemail.model Destination setBccAddresses

List of usage examples for com.amazonaws.services.simpleemail.model Destination setBccAddresses

Introduction

In this page you can find the example usage for com.amazonaws.services.simpleemail.model Destination setBccAddresses.

Prototype


public void setBccAddresses(java.util.Collection<String> bccAddresses) 

Source Link

Document

The recipients to place on the BCC: line of the message.

Usage

From source file:com.irurueta.server.commons.email.AWSMailSender.java

License:Apache License

/**
 * Method to send a text email./*from   w  w w.  java 2  s  .c om*/
 * @param m email message to be sent.
 * @return id of message that has been sent.
 * @throws MailNotSentException if mail couldn't be sent.
 */
private String sendTextEmail(AWSTextEmailMessage m) throws MailNotSentException {
    String messageId;
    long currentTimestamp = System.currentTimeMillis();
    prepareClient();
    if (!mEnabled) {
        //don't send message if not enabled
        return null;
    }

    try {
        synchronized (this) {
            //prevents throttling
            checkQuota(currentTimestamp);

            Destination destination = new Destination(m.getTo());
            if (m.getBCC() != null && !m.getBCC().isEmpty()) {
                destination.setBccAddresses(m.getBCC());
            }
            if (m.getCC() != null && !m.getCC().isEmpty()) {
                destination.setCcAddresses(m.getCC());
            }

            //if no subject, set to empty string to avoid errors
            if (m.getSubject() == null) {
                m.setSubject("");
            }

            Message message = new Message();
            m.buildContent(message);

            SendEmailResult result = mClient
                    .sendEmail(new SendEmailRequest(mMailFromAddress, destination, message));
            messageId = result.getMessageId();
            //update timestamp of last sent email
            mLastSentMailTimestamp = System.currentTimeMillis();

            //wait to avoid throwttling exceptions to avoid making any
            //further requests
            this.wait(mWaitIntervalMillis);
        }
    } catch (Throwable t) {
        throw new MailNotSentException(t);
    }
    return messageId;
}

From source file:com.irurueta.server.commons.email.AWSTextEmailMessage.java

License:Apache License

/**
 * Builds email content to be sent using an email sender.
 * @param message instance where content must be set.
 * @throws EmailException if setting mail content fails.
 *//*from ww  w .  j  a va 2 s .c om*/
@Override
protected void buildContent(Message message) throws EmailException {
    Destination destination = new Destination(getTo());
    if (getBCC() != null && !getBCC().isEmpty()) {
        destination.setBccAddresses(getBCC());
    }
    if (getCC() != null && !getCC().isEmpty()) {
        destination.setCcAddresses(getCC());
    }

    if (getSubject() != null) {
        Content subject = new Content(getSubject());
        //set utf-8 enconding to support all languages
        subject.setCharset("UTF-8");
        message.setSubject(subject);
    }

    if (getText() != null) {
        Body body = new Body();
        Content content = new Content(getText());
        //set utf-8 enconding to support all languages            
        content.setCharset("UTF-8");

        body.setText(content);
        message.setBody(body);
    }
}