Sending HTML email through amazon ses

I am sending bulk emails using amazon ses. My code is given below

public void sendMail(String sender, LinkedList<String> recipients, String subject, String body) {
    Destination destination = new Destination(recipients);
    try {
        ACCESS_KEY = EmailSender.prop.getProperty("accessKey");
        SECRET_KEY = EmailSender.prop.getProperty("secretKey");

        Content subjectContent = new Content(subject);
        Content bodyContent = new Content(body);
        Body msgBody = new Body(bodyContent);
        Message msg = new Message(subjectContent, msgBody);

        SendEmailRequest request = new SendEmailRequest(sender, destination, msg);

        AWSCredentials credentials = new BasicAWSCredentials(ACCESS_KEY, SECRET_KEY);
        AmazonSimpleEmailServiceClient sesClient = new AmazonSimpleEmailServiceClient(credentials);
        SendEmailResult result = sesClient.sendEmail(request);

        System.out.println(result + "Email sent");  
    }catch(Exception e) {
        System.out.println("Exception from EmailSender.java. Email not send");
    }

Here I have given my html content as string to the variable "body".

The mail sent successfully. But I got the html content as email. How to send html content in mail. What changes in the code will solve this issue?

Answers


From the Amazon SES developerGuide:

You should use the WithHtml method:

Content subjContent = new Content().withData("Test of Amazon SES");
Message msg = new Message().withSubject(subjContent);

// Include a body in both text and HTML formats
Content textContent = new Content().withData("Hello - I hope you're having a good day.");
Content htmlContent = new Content().withData("<h1>Hello - I hope you're having a good day.</h1>");
Body body = new Body().withHtml(htmlContent).withText(textContent);
msg.setBody(body);          

Need Your Help

10 PRINT CHR$(205.5+RND(1)); : GOTO 10 in PHP (or anything else, for that matter)

code-golf ascii-art random

Just had a 'spirited' conversation with a co-worker about the succinctness of the following BASIC statement:

How to automatically change the text size inside a div?

jquery html css font-size

I have a background image with a div. I want to write some text, but this text should change the font size through the div.