Search in sources :

Example 1 with SimpleEmailPart

use of com.amazonaws.services.pinpoint.model.SimpleEmailPart in project aws-doc-sdk-examples by awsdocs.

the class SendMessages method main.

public static void main(String[] args) throws IOException {
    try {
        Map<String, AddressConfiguration> addressMap = new HashMap<String, AddressConfiguration>();
        addressMap.put(toAddress, new AddressConfiguration().withChannelType(ChannelType.EMAIL));
        AmazonPinpoint client = AmazonPinpointClientBuilder.standard().withRegion(region).build();
        SendMessagesRequest request = (new SendMessagesRequest().withApplicationId(appId).withMessageRequest(new MessageRequest().withAddresses(addressMap).withMessageConfiguration(new DirectMessageConfiguration().withEmailMessage(new EmailMessage().withSimpleEmail(new SimpleEmail().withHtmlPart(new SimpleEmailPart().withCharset(charset).withData(htmlBody)).withTextPart(new SimpleEmailPart().withCharset(charset).withData(textBody)).withSubject(new SimpleEmailPart().withCharset(charset).withData(subject)))))));
        System.out.println("Sending message...");
        client.sendMessages(request);
        System.out.println("Message sent!");
    } catch (Exception ex) {
        System.out.println("The message wasn't sent. Error message: " + ex.getMessage());
    }
}
Also used : EmailMessage(com.amazonaws.services.pinpoint.model.EmailMessage) MessageRequest(com.amazonaws.services.pinpoint.model.MessageRequest) SendMessagesRequest(com.amazonaws.services.pinpoint.model.SendMessagesRequest) HashMap(java.util.HashMap) DirectMessageConfiguration(com.amazonaws.services.pinpoint.model.DirectMessageConfiguration) SimpleEmailPart(com.amazonaws.services.pinpoint.model.SimpleEmailPart) AmazonPinpoint(com.amazonaws.services.pinpoint.AmazonPinpoint) AddressConfiguration(com.amazonaws.services.pinpoint.model.AddressConfiguration) SimpleEmail(com.amazonaws.services.pinpoint.model.SimpleEmail) IOException(java.io.IOException)

Aggregations

AmazonPinpoint (com.amazonaws.services.pinpoint.AmazonPinpoint)1 AddressConfiguration (com.amazonaws.services.pinpoint.model.AddressConfiguration)1 DirectMessageConfiguration (com.amazonaws.services.pinpoint.model.DirectMessageConfiguration)1 EmailMessage (com.amazonaws.services.pinpoint.model.EmailMessage)1 MessageRequest (com.amazonaws.services.pinpoint.model.MessageRequest)1 SendMessagesRequest (com.amazonaws.services.pinpoint.model.SendMessagesRequest)1 SimpleEmail (com.amazonaws.services.pinpoint.model.SimpleEmail)1 SimpleEmailPart (com.amazonaws.services.pinpoint.model.SimpleEmailPart)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1