Example usage for com.amazonaws.services.simpleemail.model Body setText

List of usage examples for com.amazonaws.services.simpleemail.model Body setText

Introduction

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

Prototype


public void setText(Content text) 

Source Link

Document

The content of the message, in text format.

Usage

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.
 *//*  www. j  av a 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);
    }
}

From source file:org.onebusaway.admin.service.impl.EmailServiceImpl.java

License:Apache License

@Override
public void sendAsync(String to, String from, String subject, StringBuffer messageBody) {
    List<String> toAddresses = new ArrayList<String>();
    for (String address : to.split(",")) {
        toAddresses.add(address);/*w ww  .j  a v a  2 s.  c om*/
    }
    Destination destination = new Destination(toAddresses);
    Body body = new Body();
    body.setText(new Content(messageBody.toString()));
    Message message = new Message(new Content(subject), body);
    SendEmailRequest sendEmailRequest = new SendEmailRequest(from, destination, message);
    Future<SendEmailResult> result = _eClient.sendEmailAsync(sendEmailRequest);
    _log.info("sent email to " + to + " with finished=" + result.isDone());
}

From source file:org.onebusaway.admin.service.impl.EmailServiceImpl.java

License:Apache License

public void sendSES(String to, String from, String subject, StringBuffer messageBody) {
    List<String> toAddresses = new ArrayList<String>();
    for (String address : to.split(",")) {
        toAddresses.add(address);/* w w w  .  j  a  v  a 2  s  . com*/
    }
    Destination destination = new Destination(toAddresses);
    Body body = new Body();
    body.setText(new Content(messageBody.toString()));
    Message message = new Message(new Content(subject), body);
    SendEmailRequest sendEmailRequest = new SendEmailRequest(from, destination, message);
    SendEmailResult result = _eClient.sendEmail(sendEmailRequest);
    _log.info("sent email to " + to + " with result=" + result);
}