Example usage for com.amazonaws.services.simpleemail.model SendEmailResult getSdkHttpMetadata

List of usage examples for com.amazonaws.services.simpleemail.model SendEmailResult getSdkHttpMetadata

Introduction

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

Prototype

public SdkHttpMetadata getSdkHttpMetadata() 

Source Link

Usage

From source file:com.adeptj.modules.aws.ses.internal.AwsSesService.java

License:Apache License

/**
 * {@inheritDoc}//  w  w  w.  java2 s.c  o m
 */
@Override
public EmailResponse sendEmail(EmailRequest emailRequest) {
    try {
        SendEmailResult result = this.asyncSES
                .sendEmail(new SendEmailRequest().withSource(this.emailConfig.from())
                        .withDestination(new Destination().withToAddresses(emailRequest.getRecipientToList())
                                .withCcAddresses(emailRequest.getRecipientCcList())
                                .withBccAddresses(emailRequest.getRecipientBccList()))
                        .withMessage(new Message()
                                .withSubject(new Content().withData(emailRequest.getSubject())).withBody(
                                        new Body().withHtml(new Content().withData(emailRequest.getBody())))));
        return new EmailResponse(result.getMessageId(), result.getSdkHttpMetadata().getHttpStatusCode(),
                result.getSdkHttpMetadata().getHttpHeaders());
    } catch (Exception ex) {
        LOGGER.error("Exception while sending email!!", ex);
        throw new AwsException(ex.getMessage(), ex);
    }
}