I recently came across a scenario where I needed to have a mailto: link include additional details, and particularly an email address in the cc field. You can configure an HTML mailto: link to include a number of fields:
- Basic Mailto: Link
- To:
- CC:
- BCC:
- Subject:
- Body:
The Mailto: Link
The Mailto: Link is a variation of the standard HTML Hyperlink. It invokes the browser to send an email when the ‘href’ attributes value starts with ‘mailto:’ as below.
<a href="mailto:">Email</a>
To: – Setting the email recipient
The To: field is the only required field of a Mailto: link. This is the email address that the generated email will be sent to.
<a href="mailto:user@example.com">Email</a>
If you wish to add multiple recipients to the To: field (or the CC: and BCC: fields as shown below) separate the addresses with commas (e.g. admin@example.com,end_user@example.com).
CC: – ‘Carbon Copy’ for adding additional recipients
Note: When adding items to your mailto: link make sure to add a question mark (?) after the ‘To:’ field.
<a href="mailto:user@example.com?cc=other_user@example.com">Email</a>
BCC: – ‘Blind Carbon Copy’ for adding hidden recipients
You can also add recipients to the email who will be hidden from the To: and CC: recipients within the email message, by using the BCC: field. If you have already added a CC: (or any other element) to your mailto: link, you should include an ampersand (&) before each additional item.
<a href="mailto:user@example.com?cc=other_user@example.com&bcc=admin@example.com">Email</a>
Subject: – Adding subjects to your emails
The Subject: field in your mailto: link will allow you to set the emails subject.
<a href="mailto:user@example.com?cc=other_user@example.com&bcc=admin@example.com&subject=Test%20Email">Email</a>
Note: A mailto: link can not contain spaces. When adding a Subject: or Body: field use ‘%20’ instead.
Body: – Making an email template
The final variable of a mailto: link is the Body: attribute. This allows you to set a specific message within the body of the message. You can enter a line such as, “I would like to unsubscribe from this poop.″ with the following:
<a href="mailto:recipient@domain.com?cc=other@domain.com&bcc=hidden@domain.com&subject=Test%20Email&body=I%20would%20like%20to%20unsubscribe%20from%20this%20poop.">Email</a>
Summary
A fully formed mailto: link can be very useful! Use it, and be more awesome!!
Leave a Reply