2012-12-10 13 views
8

मैं अमेज़ॅन एसएस का उपयोग करके थोक ईमेल भेज रहा हूं। मेरे कोड के नीचेअमेज़ॅन सेस के माध्यम से HTML ईमेल भेजना

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

दिया जाता है यहाँ मैं चर "शरीर" करने के लिए स्ट्रिंग के रूप में मेरी html सामग्री दी है।

मेल सफलतापूर्वक भेजा गया। लेकिन मुझे एचटीएमएल सामग्री ईमेल के रूप में मिला। मेल में एचटीएमएल सामग्री कैसे भेजें। कोड में क्या परिवर्तन इस मुद्दे को हल करेंगे?

+0

क्या प्राप्त ईमेल कैसा दिखता है:

आप WithHtml विधि का उपयोग करना चाहिए? "मुझे HTML सामग्री को ईमेल के रूप में मिला" का क्या मतलब है? आप किस ईमेल क्लाइंट में मेल देख रहे हैं? – bdares

+0

मुझे के रूप में मेल मिला ..... मेरा मतलब है टैग से भरा मूल HTML कोड – Neeraj

+0

आप किस ईमेल क्लाइंट का उपयोग कर रहे हैं? – bdares

उत्तर

26
Amazon SES developerGuide से

:

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);   
संबंधित मुद्दे