0

Amazon Simple Email Service Java API を使用して受信者にメールを送信しています。タグ内のメール本文にURLを送信しています。私のユースケースでは、ユーザーが受け取った URL をダブルクリックして何らかのアクションを促す必要があります。(確認メールなど)

問題は、受信中に URL がエンコードされることです。ダブルクリックすると、ページが見つかりません (404) エラーが発生します。

元の URL : http://something.com/confirm/email=abc@hotmail.com®Key=somekey&confirm=true メールでこの URL をダブルクリックすると、リンクがアドレス バーに次のように開かれます: http://something.com /confirm/email=abc%40hotmail.com%26regKey=somekey%26confirm=true

AmazonSimpleEmailServiceClientを使用しています。コードは以下のとおりです。

    SendEmailRequest request = new SendEmailRequest().withSource(sourceAddress);

String confirmationURL="http://something.com/confirm/email=abc@hotmail.com&regKey=somekey&confirm=true";

            List<String> toAddresses = new ArrayList<String>();
            toAddresses.add(toEmail);

            Destination dest = new Destination().withToAddresses(toAddresses);
            request.setDestination(dest);

            Content subjContent = new Content().withData("Confirmation Request");
            Message msg = new Message().withSubject(subjContent);

            // Include a body in both text and HTML formats
            Content textContent = new Content().withData("Dear please go to the following URL:"+
                    confirmationURL+"\n\n");

            Content htmlContent = new Content().withData("<p>Dear please go to the following URL:</p>"+
                    "<p><a href=\""+confirmationURL+"\">"+confirmationURL+"</a></p>");

             Body body = new Body().withHtml(htmlContent).withText(textContent);
            msg.setBody(body);
            request.setMessage(msg)

アップデート

この問題は、受信者の電子メールがhotmail.comにある場合にのみ発生します。なぜマイクロソフトはいつも違うことをしなければならないのですか? 誰か助けて!

4

1 に答える 1

0

クラス java.net.URLEncoder を使用します。

String confirmationURL = URLEncoder.encode( "http://something.com/confirm/email=abc@hotmail.com&regKey=somekey& confirm=true", "UTF-8");
于 2012-08-27T17:06:50.347 に答える