I am trying to send an email through AWS SES using Java SDK 2. Although I am able to send the email successfully. I wanted to know how to set the Configuration Set while sending out the email in Java SDK 2.
I am trying to follow the code similar to the one provided in the AWS documentation but it does not specify how to add the configuration set to the email request object.
/* EMAIL MESSAGE BODY SETUP */
System.out.println("Attempting to send an email through Amazon SES " + "using the AWS SDK for Java...");
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
message.writeTo(outputStream);
ByteBuffer buf = ByteBuffer.wrap(outputStream.toByteArray());
byte[] arr = new byte[buf.remaining()];
buf.get(arr);
SdkBytes data = SdkBytes.fromByteArray(arr);
RawMessage rawMessage = RawMessage.builder()
.data(data)
.build();
SendRawEmailRequest rawEmailRequest = SendRawEmailRequest.builder()
.rawMessage(rawMessage)
.build();
client.sendRawEmail(rawEmailRequest);
Wanted help with adding the configuration set to the rawEmailRequest
AWS Java SDK 1 specifies the use of configuration set in the code example. (Below)
AmazonSimpleEmailService client =
AmazonSimpleEmailServiceClientBuilder.standard()
// Replace US_WEST_2 with the AWS Region you're using for
// Amazon SES.
.withRegion(Regions.US_WEST_2).build();
SendEmailRequest request = new SendEmailRequest()
.withDestination(
new Destination().withToAddresses(TO))
.withMessage(new Message()
.withBody(new Body()
.withHtml(new Content()
.withCharset("UTF-8").withData(HTMLBODY))
.withText(new Content()
.withCharset("UTF-8").withData(TEXTBODY)))
.withSubject(new Content()
.withCharset("UTF-8").withData(SUBJECT)))
.withSource(FROM)
// Comment or remove the next line if you are not using a
// configuration set
.withConfigurationSetName(CONFIGSET);
client.sendEmail(request);
Thank you for the help!!