Example usage for com.amazonaws.services.simpleemail.model RawMessage getData

List of usage examples for com.amazonaws.services.simpleemail.model RawMessage getData

Introduction

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

Prototype


public java.nio.ByteBuffer getData() 

Source Link

Document

The raw data of the message.

Usage

From source file:com.kolich.aws.services.ses.impl.KolichSESClient.java

License:Open Source License

@Override
public Either<HttpFailure, SendRawEmailResult> sendRawEmail(final RawMessage message, final String from,
        final List<String> destinations) {
    return new AwsSESHttpClosure<SendRawEmailResult>(client_, SC_OK, new SendRawEmailResultStaxUnmarshaller()) {
        @Override//from   www  .jav a  2 s  . c o  m
        public void validate() throws Exception {
            checkNotNull(message, "Raw message cannot be null.");
            checkNotNull(from, "From email address cannot be null.");
            checkState(isValidEmail(from),
                    "Invalid 'from' email address, " + "did not match expected email pattern.");
        }

        @Override
        public void prepare(final AwsHttpRequest request) throws Exception {
            request.addParameter(SES_ACTION_PARAM, SES_ACTION_SENDEMAIL);
            request.addParameter(SES_SOURCE_ADDRESS_PARAM, from);
            // Destination addresses
            for (int i = 0; i < destinations.size(); i++) {
                final String destination = destinations.get(i);
                request.addParameterOpt(String.format("%s.%s", SES_DESTINATIONS_PARAM, i + 1), destination);
            }
            // Message body
            request.addParameter(SES_RAW_MESSAGE_DATA_PARAM, fromByteBuffer(message.getData()));
        }
    }.post();
}