This page demonstrates how to create HTML email links. Email links are ordinary HTML links. The difference is that, instead of opening another web page, an email link opens the user's email program with the email address already in the "To:" field.
Other fields, such as the "Subject:", can be pre-populated too.
Create a Basic Email Link
Like other HTML links, email links are created using the HTML
<a> tag. The
<a> tag stands for "anchor" tag. As with other HTML links, you need to fill out the
href attribute. The difference with email links is that, you need to enter the email address, preceded by
mailto:. Again, as with other HTML links, you also need to specify the text you'd like to be linked, and close the tag.
The above link should open the user's email client/program with
[email protected] already filled into the "To:" field.
Automatically Add a Subject Line
You can pre-populate the subject line by following the email address
?Subject= followed by the subject line. Like this:
Automatically Add the Body Text
You can also pre-populate the body of the email. To do this, simply follow the subject with
&Body= followed by the body text. Like this:
It is good practice to specify a space between words by using
%20. You may notice that this doesn't appear to be needed, but some browsers/email clients may have problems if you don't specify it. Therefore, to reduce potential compatibility issues, the above email link could be re-written to this.
Adding Carriage Returns
You can add a carriage return by using
%0D%0A within your code. This simply forces the text over to the next line. Like this:
You can add "cc" in a similar fashion. Simply add
cc, preceded by an ampersand. Or, if you prefer to keep the email addresses together, place the
cc straight after the question mark (followed by an ampersand to delimit the subject line). Here, we add the
cc in between the first email address and the subject line:
And as if "cc" isn't enough, you can also add "bcc" in the same fashion. Here we add a "bcc" after the "cc":
About the "?" and "&"
You may be wondering when to use the question mark and when to use the ampersand.
You only use the question mark once, and only if you are adding parameters to the email. The question mark must only follow the very first email address (i.e. the one at
mailto:). Any other parameters must be preceded by an ampersand.