internalSendEmail(to, from, replyTo, subject, htmlBody, textBody);
}
}
private String internalSendEmail(String to, String from, String replyTo, String subject, String htmlBody, String textBody) {
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);