Example usage for com.amazonaws.services.simpleemail.model Message setSubject

List of usage examples for com.amazonaws.services.simpleemail.model Message setSubject

Introduction

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

Prototype


public void setSubject(Content subject) 

Source Link

Document

The subject of the message: A short summary of the content, which will appear in the recipient's inbox.

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.
 *//*from   w w w .j  a  v  a 2 s .c o  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.r573.enfili.common.resource.cloud.aws.ses.SesManager.java

License:Apache License

public void sendEmailToSingleRecipient(String recipient, String subject, String emailContentText,
        String emailContentHtml, String sender) {
    SendEmailRequest request = new SendEmailRequest().withSource(sender);

    List<String> toAddresses = new ArrayList<String>();
    toAddresses.add(recipient);/*  w  ww.j av  a2s. c  o  m*/
    Destination dest = new Destination().withToAddresses(recipient);
    request.setDestination(dest);

    Content subjectContent = new Content().withData(subject);
    Message msg = new Message();
    msg.setSubject(subjectContent);

    Body body = new Body();
    if (emailContentText != null) {
        Content textContent = new Content().withData(emailContentText);
        body.withText(textContent);
    }
    if (emailContentHtml != null) {
        Content htmlContent = new Content().withData(emailContentHtml);
        body.withHtml(htmlContent);
    }

    msg.setBody(body);

    request.setMessage(msg);

    client.sendEmail(request);
}

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

License:Apache License

public void sendJava(String to, String from, String subject, StringBuffer messageBody) {
    try {/* w  w  w. j  ava  2s .co m*/
        javax.mail.Message msg = new MimeMessage(_session);
        msg.setFrom(new InternetAddress(from));
        msg.addRecipient(javax.mail.Message.RecipientType.TO, new InternetAddress(to));
        msg.setSubject(subject);
        if (messageBody != null) {
            msg.setText(messageBody.toString());
        }
        msg.saveChanges();
        if (!_transport.isConnected()) {
            _transport.connect();
        }
        _transport.send(msg);
    } catch (Exception e) {
        _log.error("sendJava failed", e);
    }
}