2012-12-10 25 views
8

Amazon ses kullanarak toplu e-postalar gönderiyorum. KodumAmazon ses üzerinden HTML epostası gönderme

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"); 
    } 

aşağıda verilmiştir Burada değişken "vücut" için dize olarak benim html içeriği verdik.

Posta başarıyla gönderildi. Ama html içeriğini e-posta olarak aldım. Postada html içeriği nasıl gönderilir. Kodda hangi değişiklikler bu sorunu çözecek? Amazon SES developerGuide itibaren

+0

neye benzer Alınan eposta görünüyor:

Sen WithHtml yöntemi kullanmak gerekir? Ne demek "html içeriğini e-posta olarak aldım"? Postayı hangi e-posta istemcisiyle görüntülüyorsunuz? – bdares

+0

numaralı postalarım var ..... Demek istediğim orijinal html kodu etiketlerle dolu – Neeraj

+0

Hangi e-posta istemcisini kullanıyorsunuz? – bdares

cevap

26

:

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);   
İlgili konular