How to add a subject to a mailto anchor in HTML

Updated: 12/09/2018 by Computer Hope
Notification for new e-mail.

Adding "subject" to the mailto HTML (HyperText Markup Language) tag is a way to help direct e-mails when listing more than one e-mail address on your website or blog.

Using the mailto in the a href HTML tag lets you send an e-mail using the installed e-mail client. To add a subject to that e-mail, add ?subject=<subject> to the mailto tag.

For example, the complete tag would look similar to the example below.

<a href="mailto:[email protected]?subject=Testing out mailto!">First Example</a>

Alternatively, add body text by adding &body=body to the end of the tag, as shown in the example below.

<a href="mailto:[email protected]?subject=Testing out mailto!&body=This is only a test!">Second Example</a>

Include &cc= or &bcc= to fill out the CC (carbon copy) and BCC (Blind Carbon Copy) fields.

Note

If you are using a web mail service, such as Yahoo! mail or Gmail, the code above does not open these services to create an e-mail. These links are only designed to create and send e-mail from an e-mail client installed on the computer, such as Outlook and Thunderbird.

Examples

First Example

Second Example