List of usage examples for com.amazonaws.services.simpleemail.model Message setBody
public void setBody(Body body)
The message body.
From source file:com.erudika.para.email.AWSEmailer.java
License:Apache License
@Override public boolean sendEmail(List<String> emails, String subject, String body) { if (emails != null && !emails.isEmpty() && !StringUtils.isBlank(body)) { final SendEmailRequest request = new SendEmailRequest().withSource(Config.SUPPORT_EMAIL); Destination dest = new Destination().withToAddresses(emails); request.setDestination(dest);// ww w. j ava 2s . c o m Content subjContent = new Content().withData(subject); Message msg = new Message().withSubject(subjContent); // Include a body in both text and HTML formats Content textContent = new Content().withData(body).withCharset(Config.DEFAULT_ENCODING); msg.setBody(new Body().withHtml(textContent)); request.setMessage(msg); Para.asyncExecute(new Runnable() { public void run() { sesclient.sendEmail(request); } }); return true; } return false; }
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. ja 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.oneops.antenna.senders.aws.EmailService.java
License:Apache License
/** * Send email.//from ww w . j av a2s. 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; }
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 w w. ja v a2 s. 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:com.streamreduce.core.service.EmailServiceImpl.java
License:Apache License
private String internalSendEmail(String to, String from, String replyTo, String subject, String htmlBody, String textBody) {// w ww .j ava2s . com SendEmailRequest request = new SendEmailRequest().withSource(from).withReplyToAddresses(replyTo); List<String> toAddresses = new ArrayList<>(); toAddresses.add(to); Destination dest = new Destination().withToAddresses(toAddresses); request.setDestination(dest); Content subjContent = new Content().withData(subject); Message msg = new Message().withSubject(subjContent); // Include a body in both text and HTML formats Body theBody = new Body(); if (textBody != null) { theBody.withText(new Content().withData(textBody)); } if (htmlBody != null) { theBody.withHtml(new Content().withData(htmlBody)); } msg.setBody(theBody); request.setMessage(msg); // Call Amazon SES to send the message String messageId = null; try { SendEmailResult result = simpleEmailServiceClient.sendEmail(request); messageId = result.getMessageId(); } catch (AmazonClientException e) { logger.debug("[SES EMAIL] AWS AmazonClientException " + e.getMessage()); logger.error("Caught an AddressException, which means one or more of your " + "addresses are improperly formatted." + e.getMessage()); } catch (Exception e) { logger.debug("[SES EMAIL] AWS General Exception " + e.getMessage()); } return messageId; }
From source file:net.smartcosmos.plugin.service.aws.email.AwsEmailService.java
License:Apache License
@Override public void sendEmail(String to, String subject, String plainMessage, String htmlMessage) { String from = context.getConfiguration().getAdminEmailAddress(); SendEmailRequest request = new SendEmailRequest().withSource(from); List<String> toAddresses = new ArrayList<String>(); toAddresses.add(to);//from ww w .ja v a 2s .c o m Destination destination = new Destination().withToAddresses(toAddresses); request.setDestination(destination); Content subjContent = new Content().withData(subject); Message msg = new Message().withSubject(subjContent); Content textContent = new Content().withData(plainMessage); Content htmlContent = new Content().withData(htmlMessage); Body body = new Body().withHtml(htmlContent).withText(textContent); msg.setBody(body); request.setMessage(msg); AmazonSimpleEmailServiceClient client = new AmazonSimpleEmailServiceClient(credentials); try { client.sendEmail(request); LOG.info("Registration confirmation sent to email " + to); } catch (Exception e) { e.printStackTrace(); } }