crus4

logo

Create a Link to Send Email in HTML


HTML  anchor tag (<a>) gives us an option to specify an email address to send an email.

To create a link that allows the user to send an email when clicked, we can use the “mailto” attribute in an HTML anchor tag. Here’s an example:

<a href="mailto:youremail@gmail.com">Send Email</a>

In an example above, “youremail@gmail.com” is the email address of the recipient. When the user clicks the “Send Email” link, their default email client will open with a new message addressed to “youremail@gmail.com“.

To see how it really works run the below code and put your email address in place of youremail@gmail.com and see how it works.

<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h1>Create Email as a Link</h1>
<a href="mailto:youremail@gmail.com">Send Email</a>
</body>
</html>

HTML – Set Subject and Message

We can also add additional parameters to the “mailto” attribute to pre-fill the subject line and body of the email. Here’s an example:

<a href="mailto:youremail@gmail.com?subject=Hello&body=How%20are%20you%3F">Send Email</a>

In an above example, the subject line of the email will be “Hello” and the body will be “How are you?”. Note that spaces need to be encoded as “%20” and the question mark needs to be encoded as “%3F”.

<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h1>Create Email as a Link</h1>
<a href="mailto:youremail@gmail.com?subject=Hello&body=How%20are%20you%3F">Send Email</a>
</body>
</html>

Share This Post!

Create a Link to Send Email in HTML