0
我正在使用Amazon Simple Email Service Java API向接收者发送邮件。 我在标签内发送邮件正文中的URL。 我的用例要求用户双击收到的URL来提示一些操作。 (如确认邮件)如何在没有编码的情况下在电子邮件中发送url
问题是URL在接收时被编码。双击它会导致找不到页面(404)错误。
原始地址: http://something.com/confirm/email=abc%40hotmail.com%26regKey=somekey%26confirm=true
我使用AmazonSimpleEmailServiceClient:http://something.com/confirm/[email protected]®Key=somekey&confirm=true 当我双击邮件上的这个URL,链接在地址栏中显示为打开。代码如下:
SendEmailRequest request = new SendEmailRequest().withSource(sourceAddress);
String confirmationURL="http://something.com/confirm/[email protected]®Key=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)
UPDATE
刚刚发现,当收件人的电子邮件是在hotmail.com这个问题只发生。为什么微软总是需要做不同的事情?有人帮忙!
我只想做相反。它已经被编码了。 – shashankaholic
对不起,URLDecoder.decode()应该做的伎俩。 – JamesB
其实编码是在hotmail收件人。我无法解码。 – shashankaholic