2012-12-10 16 views
8

amazon sesを使用してバルクメールを送信しています。私のコードはamazon経由で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コンテンツを与えています。

メールが正常に送信されました。しかし、私は電子メールとしてhtmlコンテンツを取得しました。メールでhtmlコンテンツを送信する方法。コードのどのような変更がこの問題を解決しますか? Amazon SES developerGuideから

+0

あなたはWithHtmlメソッドを使用する必要がありますか? 「私はHTMLコンテンツを電子メールとして受け取った」とはどういう意味ですか?どのメールクライアントでメールを表示していますか? – bdares

+0

私はとしてメールを受け取っています.....タグでいっぱいの元のHTMLコードを意味します – Neeraj

+0

あなたはどんな電子メールクライアントを使用していますか? – bdares

答えて

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);   
関連する問題