use of software.amazon.awssdk.services.ses.model.SendEmailRequest in project aws-doc-sdk-examples by awsdocs.
the class SendEmail method sendMsg.
public void sendMsg(Set<String> unqiueKeys) {
Region region = Region.US_EAST_1;
SesClient client = SesClient.builder().region(region).build();
String sender = "<Enter the sender email address>";
String recipient = "<Enter the recipient email address>";
// Set the HTML body.
String bodyHTML = "<html> <head></head> <body><p> The following images contains PPE gear " + "<ol> ";
// Persist the data into a DynamoDB table.
for (String myKey : unqiueKeys) {
bodyHTML = bodyHTML + "<li> " + myKey + "</li>";
}
bodyHTML = bodyHTML + "</ol></p></body></html>";
Destination destination = Destination.builder().toAddresses(recipient).build();
Content content = Content.builder().data(bodyHTML).build();
Content sub = Content.builder().data("PPE Information").build();
Body body = Body.builder().html(content).build();
Message msg = Message.builder().subject(sub).body(body).build();
SendEmailRequest emailRequest = SendEmailRequest.builder().destination(destination).message(msg).source(sender).build();
try {
System.out.println("Attempting to send an email through Amazon SES " + "using the AWS SDK for Java...");
client.sendEmail(emailRequest);
} catch (SesException e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
}
}
Aggregations