Email Link

This page demonstrates how to create an HTML email link. That is, a link that when clicked on, opens the user's email software with the destination email address already populated.

To create an email link, you use the same code that you'd use with any other HTML link (i.e. you use the <a> tag). The only difference is that you need to specify "mailto:" in the URL part - along with the destination email address.

Here's an Example:

Source CodeResult
Email Barney Today!

As you can see, clicking this link opens up your default mail client (software) with the destination email address ([email protected]) already populated in the "To:" field.

Note: If clicking the link does nothing, you may need to configure a default mail client for your computer.

Adding "cc" and "bcc"

You can add a "carbon copy" and a "blind carbon copy" to your list of email recipients. You can do this with the use of ?cc and/or ?bcc. Note that if you use both, the second parameter (and subsequent parameters) should be preceded by an ampersand (&) instead of a question mark. In other words, only the first parameter should have a question mark. All others should be preceded by an ampersand.

Example:

Source CodeResult
Email Barney Today!

Adding a Subject Line

You can also pre-populate the subject line. To do this, simply add ?subject= followed by whatever you want to appear as the subject of the email.

Example:

Source CodeResult
Email Barney Today!

Adding Body Text

You can also pre-populate the actual content of the email using a similar technique to adding the subject line. To add body text to your email, add &body= followed by whatever you want to appear within the email's contents.

Example:

Source CodeResult
Email Barney Today!

Spaces, Carriage Returns, and Ampersands

When creating an email link, as with any HTML link, you should use &amp; to represent the ampersand (&).

It's also good practice to use %20 in place of all spaces and %0D%0A in place of all carriage returns (i.e. when you want a space, such as when you'd normally use the "Enter" key).

When I say that it's "good practice" to do this, I mean, some browsers/email clients behave differently and may or may not show spaces and carriage returns the way you'd like. Therefore, using the method outlined here will ensure that your users see what you intend them to see.

Example:

Source CodeResult
Email Barney Today!