Outlook handling of quoted url parameters in mailto link
Asked Answered
T

2

3

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://mcmap.net/q/832437/-create-mailto-hyperlink-that-will-open-in-outlook-with-a-hyperlink-in-the-body

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://mcmap.net/q/832438/-mailto-problem and https://mcmap.net/q/832439/-why-won-39-t-mailto-include-link-parameters

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:[email protected]?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.

Therese answered 14/5, 2012 at 16:33 Comment(0)
C
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:[email protected]?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:[email protected]?subject=This is a subject&body=http%3A%2F%2Fsomeserver.somedomain%2Fsomepage.aspx%3Fid%3D1234%26somekey%3D%2522somevalue%2522">A link</a>
Chlamydeous answered 10/6, 2013 at 13:7 Comment(1)
A very interesting and helpful aspect in this answer for me was, that you do not only have to encode the ampersand but also the percent sign before it, which turns it into %2526. Thanks a lot!Stadium
A
0

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

%20 = space

%0D = new line

%3C = "<"

%3E = ">"

<html>
<body>hi
 <a href="mailto:[email protected]?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>
Articulate answered 3/2, 2016 at 4:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.