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

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

Introduction

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

Prototype


public void setCcAddresses(java.util.Collection<String> ccAddresses) 

Source Link

Document

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

Usage

From source file:com.devnexus.ting.core.service.integration.AmazonSesSender.java

License:Apache License

public void sendUsingSendgrid(GenericEmail email) {

    final Destination destination = new Destination(email.getTo());
    destination.setCcAddresses(email.getCc());

    final Content subject = new Content(email.getSubject());
    final Content htmlContent = new Content().withData(email.getHtml());
    final Content textContent = new Content().withData(email.getText());

    final Body body = new Body().withHtml(htmlContent).withText(textContent);

    final Message message = new Message().withSubject(subject).withBody(body);

    final SendEmailRequest request = new SendEmailRequest().withSource(email.getFrom())
            .withDestination(destination).withMessage(message);

    final Region REGION = Region.getRegion(Regions.US_EAST_1);
    client.setRegion(REGION);/*from  w w w .j  a  v a  2 s.  co  m*/

    // Send the email.
    client.sendEmail(request);
    LOGGER.info("Email sent to {}", email.getTo());

}

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

License:Apache License

/**
 * Method to send a text email.//from  w w  w.j av a 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.
 *//*w  w  w  .  j av  a2 s. co m*/
@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);
    }
}

From source file:com.oneops.antenna.senders.aws.EmailService.java

License:Apache License

/**
 * Send email.//from  w  w w . j a  v a  2s .  c o m
 *
 * @param eMsg the e msg
 * @return true, if successful
 */
public boolean sendEmail(EmailMessage eMsg) {

    SendEmailRequest request = new SendEmailRequest().withSource(eMsg.getFromAddress());
    Destination dest = new Destination().withToAddresses(eMsg.getToAddresses());
    dest.setCcAddresses(eMsg.getToCcAddresses());
    request.setDestination(dest);
    Content subjContent = new Content().withData(eMsg.getSubject());
    Message msg = new Message().withSubject(subjContent);
    Content textContent = new Content().withData(eMsg.getTxtMessage());
    Body body = new Body().withText(textContent);
    if (eMsg.getHtmlMessage() != null) {
        Content htmlContent = new Content().withData(eMsg.getHtmlMessage());
        body.setHtml(htmlContent);
    }
    msg.setBody(body);
    request.setMessage(msg);
    try {
        emailClient.sendEmail(request);
        logger.debug(msg);
    } catch (AmazonClientException e) {
        logger.error(e.getMessage());
        return false;
    }
    return true;
}