How to create an email link in HTML?

Email link (know also as mailto link) is a special link type that opens user’s email client after the click. It can be very basic or contains additional parameters. When you pass additional parameters like body, subject, CC, or BCC, then user’s email client will open with pre-filled fields. This can be very useful, for example to encourage users to send feedback emails.

How to create a very basic email link in HTML?

To create a basic type link, use below HTML markup (change johndoe@gmail.com to your email address):

<a href="mailto:johndoe@gmail.com">johndoe@gmail.com</a>

How to pass pre-filled message in email link?

To pass pre-filled message in email link you can pass an additional body parameter like below:

<a href="mailto:johndoe@gmail.com?body=Example%20message">johndoe@gmail.com</a>

In this example, you can notice %20 text. This is encoded space character. To pass some special characters (like space) in the link, you have to use URL-encoded format. You can do this by using this simple tool – https://www.urlencoder.org

How to pass other data like subject, CC or BCC?

Similarly, as above, you have to pass additional parameters.

To pass subject:

<a href="mailto:johndoe@gmail.com?subject=Feedback%20about%20service">johndoe@gmail.com</a>

To pass CC:

<a href="mailto:johndoe@gmail.com?cc=janedoe@gmail.com">johndoe@gmail.com</a>

To pass BCC:

<a href="mailto:johndoe@gmail.com?bcc=janedoe@gmail.com">johndoe@gmail.com</a>

How to pass multiple parameters together?

To pass multiple parameters together you have to use & character as a delimiter, for example:

<a href="mailto:johndoe@gmail.com?body=Example%20message&subject=Feedback%20about%20service">johndoe@gmail.com</a>

How to add multiple email recipients?

To add multiple email recipients, you have to use comma character as delimiter:

<a href="mailto:johndoe@gmail.com,janedoe@gmail.com">johndoe@gmail.com and janedoe@gmail.com</a>

How to add a line break in the email message?

Similarly, as we used %20 as encoded space character, we have to use %0D%0A as encoded line break character:

<a href="mailto:johndoe@gmail.com?body=Line1%0D%0ALine2">johndoe@gmail.com</a>

Leave a Reply

Your email address will not be published. Required fields are marked *