tags:

views:

183

answers:

4

I'm trying to set up the following mailto: link:

<a href='mailto:[email protected]?subject=Testing&body=http://www.google.com?foo=1&amp;bar=2'&gt;Send mail</a>

However the second argument (bar) is cut off because it is seen as an argument of the mailto link and not the link I'm putting in the body. I tried &amp; but it does the same thing since it's being rendered into the link.

A: 

Try putting the value for body into quotes like:

'mailto:[email protected]?subject=Testing&body="http://www.google.com?foo=1&amp;bar=2"'

Nvm, turns out putting %26 works instead of ampersand.

Dmitri Farkov
+2  A: 

Use "%26" instead or use urluncoding like suggested in another answer. For PHP rawurlencode works well.

<a href='mailto:[email protected]?subject=Testing&body=http://www.google.com?foo=1%26bar=2'&gt;Send mail</a>
Buggabill
+5  A: 

Hi,

What about something like this :

<a href='mailto:[email protected]?subject=Testing&amp;body=http%3A%2F%2Fwww.google.com%3Ffoo%3D1%26bar%3D2'>Send mail</a>

ie, urlencoding the whole body field, to make sure nothing causes any problem ?

Pascal MARTIN
bobince
A: 

Use %26 as &.. its the html escape code for &.

<a href='mailto:[email protected]?subject=Testing&body=http://www.google.com?foo=1%26bar=2'&gt;Send mail</a>

Jonas B