Search in sources :

Example 1 with AddressConfiguration

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

the class SendMessage method main.

public static void main(String[] args) throws IOException {
    try {
        Map<String, AddressConfiguration> addressMap = new HashMap<String, AddressConfiguration>();
        addressMap.put(destinationNumber, new AddressConfiguration().withChannelType(ChannelType.SMS));
        AmazonPinpoint client = AmazonPinpointClientBuilder.standard().withRegion(region).build();
        SendMessagesRequest request = new SendMessagesRequest().withApplicationId(appId).withMessageRequest(new MessageRequest().withAddresses(addressMap).withMessageConfiguration(new DirectMessageConfiguration().withSMSMessage(new SMSMessage().withBody(message).withMessageType(messageType).withOriginationNumber(originationNumber).withSenderId(senderId).withKeyword(registeredKeyword))));
        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 : MessageRequest(com.amazonaws.services.pinpoint.model.MessageRequest) SendMessagesRequest(com.amazonaws.services.pinpoint.model.SendMessagesRequest) SMSMessage(com.amazonaws.services.pinpoint.model.SMSMessage) HashMap(java.util.HashMap) DirectMessageConfiguration(com.amazonaws.services.pinpoint.model.DirectMessageConfiguration) AmazonPinpoint(com.amazonaws.services.pinpoint.AmazonPinpoint) AddressConfiguration(com.amazonaws.services.pinpoint.model.AddressConfiguration) IOException(java.io.IOException)

Example 2 with AddressConfiguration

use of com.amazonaws.services.pinpoint.model.AddressConfiguration 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)2 AddressConfiguration (com.amazonaws.services.pinpoint.model.AddressConfiguration)2 DirectMessageConfiguration (com.amazonaws.services.pinpoint.model.DirectMessageConfiguration)2 MessageRequest (com.amazonaws.services.pinpoint.model.MessageRequest)2 SendMessagesRequest (com.amazonaws.services.pinpoint.model.SendMessagesRequest)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 EmailMessage (com.amazonaws.services.pinpoint.model.EmailMessage)1 SMSMessage (com.amazonaws.services.pinpoint.model.SMSMessage)1 SimpleEmail (com.amazonaws.services.pinpoint.model.SimpleEmail)1 SimpleEmailPart (com.amazonaws.services.pinpoint.model.SimpleEmailPart)1