Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set a mailto link with a subject containing an ampersand (&)

Im using the following mailto link to send an email:

 <a class="share3" title="" href="mailto:?subject=@check&amp;body=@domain"> 

It works well, but sometimes my subject will contain an ampersand (&) character, and when it does my email is created without a body.

Any way to resolve this problem?

like image 636
zooblin Avatar asked May 15 '14 15:05

zooblin


People also ask

How do you mailto with subject and body?

subject=<subject> to the mailto tag. For example, the complete tag would look similar to the example below. You can also add body text by adding &body=body to the end of the tag, as shown in the example below. You can also include &cc= or &bcc= to fill out the CC and BCC fields.

How do you attach a subject to an email link?

To create a link to send email, use <a> tag, with href attribute. The mail to link is added inside the <a> tag. To add a subject, you need to add ? and then include the subject. All this comes inside the <a> tag.


Video Answer


1 Answers

In order to get special/reserved characters into a URL, you must encode them - to get an & to work, it must be encoded to %26.

More details here: http://www.w3schools.com/tags/ref_urlencode.asp

like image 133
edcs Avatar answered Oct 12 '22 13:10

edcs