Outlook handling of quoted url parameters in mailto link

左心房为你撑大大i 提交于 2019-12-11 01:11:45

问题


I'm attempting to populate the body of a mailto link with an html link. The target browser is IE 7+ and mail client is Outlook 2007+. Before I ask my question, i'll acknowledge the fact that the body parameter is intended for short text messages as called out here:

https://stackoverflow.com/a/4304779/573083

and detailed here:

The special "body" indicates that the associated is the body of the message. The "body" field value is intended to contain the content for the first text/plain body part of the message. The "body" pseudo header field is primarily intended for the generation of short text messages for automatic processing (such as "subscribe" messages for mailing lists), not for general MIME bodies. Except for the encoding of characters based on UTF-8 and percent-encoding, no additional encoding (such as e.g., base64 or quoted-printable; see [RFC2045]) is used for the "body" field value. As a consequence, header fields related to message encoding (e.g., Content-Transfer-Encoding) in a 'mailto' URI are irrelevant and MUST be ignored. The "body" pseudo header field name has been registered with IANA for this special purpose (see Section 8.2).

That being said, there have been a number of threads on SO with varying levels of success with inserting links in the body tag. for example: https://stackoverflow.com/a/1455881/573083 and https://stackoverflow.com/a/9138245/573083

My issue is similiar, but it is specifically with outlook rendering quoted parameters of embedded links. I currently have the following that is almost working:

<a href="mailto:someaddress@somedomain.com?subject=This is a subject&body=http://someserver.somedomain/somepage.aspx?id=1234%26somekey=%22somevalue%22">A link</a>

A partial link appears correctly in the outlook body, however outlook is not including the final quoted url parameter ("somevalue") in the link; the ="somevalue" is just appearing as plain text. Viewing the source of the email message shows that outlook is closing the enclosing <a> tag as it is interpreting the %22 as the end of the link. I've attempted to escape the %22 with %2f, /, ' - to no avail. I believe that I need the correct sequence for outlook to understand that the %22 should be included in the link, and not as the closure of the enclosing link.

Any help would be appreciated.


回答1:


Judging by the ?, you haven't encoded the body component.

> encodeURIComponent("http://someserver.somedomain/somepage.aspx?id=1234%26somekey=%22somevalue%22") 
"http%3A%2F%2Fsomeserver.somedomain%2Fsomepage.aspx%3Fid%3D1234%2526somekey%3D%2522somevalue%2522" 

So the code should be:

<a href="mailto:someaddress@somedomain.com?subject=This is a subject&body=http%3A%2F%2Fsomeserver.somedomain%2Fsomepage.aspx%3Fid%3D1234%2526somekey%3D%2522somevalue%2522">A link</a>

Or more likely:

<a href="mailto:someaddress@somedomain.com?subject=This is a subject&body=http%3A%2F%2Fsomeserver.somedomain%2Fsomepage.aspx%3Fid%3D1234%26somekey%3D%2522somevalue%2522">A link</a>



回答2:


I would put the link inside "<" & ">".

%20 = space

%0D = new line

%3C = "<"

%3E = ">"

<html>
<body>hi
 <a href="mailto:someaddress@somedomain.com?subject=This is a subject&body=Hi,%0DThis%20is%20a%20body%0DAlso%20this%20is%20a%20link%20%3Chttp%3A%2F%2Fsomeserver.somedomain%2Fsomepage.aspx%3Fid%3D1234%26somekey%3D%22somevalue%22%3E%20have%20fun.">A link</a></body>

</html>


来源:https://stackoverflow.com/questions/10587424/outlook-handling-of-quoted-url-parameters-in-mailto-link

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!