0

我正在使用 Amazon Simple Email Service java API 向收件人发送邮件。我在标签内的邮件正文中发送 URL。我的用例要求用户双击收到的 URL 以提示一些操作。(如确认邮件)

问题是 url 在接收时被编码。双击它会给出找不到页面(404)错误。

原始 URLhttp ://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 回答