How to Create a Link to Send Email in HTML ?
Last Updated :
04 Apr, 2024
Incorporating email links into HTML pages facilitates a smooth way for users to send a message directly from the webpage. We will see how to create these email links, making your web pages user-friendly and interactive.
Using Mailto Protocol with Predefined Subject
To create a link to send an email in HTML, we use the mailto protocol. The basic structure for creating a link to send an email in HTML uses the standard anchor tag <a> but with the href attribute pointing to a special mailto protocol instead of a regular URL. After the email address, we can add a question mark (?) to separate parameters. We use the keyword subject followed by an equal sign (=) and then the text to add the subject.
Example: Creating a link to send email in HTML Using Mailto Protocol with a Predefined Subject
HTML
<!DOCTYPE html>
<html>
<head>
<title>Email Link with Subject</title>
</head>
<body>
<h2>Send Email</h2>
<a href="mailto:youremail@example.com
?subject=Saying%20hello%20from%20GFG">
Send Email With Subject
</a>
</body>
</html>
Output :
Email Link with Predefined Subject
Creating a Link to send Emails with predefined CC and BCC
To define BCC recipient we use the “bcc” attribute. Similarly, we use the “cc” attribute to define the CC recipient. We will use ampersand (&) to join parameters. We used &cc=carboncopy@email.com to add the carbon copy recipient and &bcc=blindcarboncopy@email.com to add a blind carbon copy recipient.
Example: Creating a link to send email in HTML with predefined CC (Carbon Copy) and BCC (Blind Carbon Copy)
HTML
<!DOCTYPE html>
<html>
<head>
<title>Email Link with Subject</title>
</head>
<body>
<h2>Send Email</h2>
<a href="mailto:youremail@example.com
?subject=Saying%20hello%20from%20GFG
&body=Hello%20there,%20this%20is%20predefined body
&cc=carboncopy@email.com
&bcc=blindcarboncopy@email.com
">
Send Email With CC and BCC
</a>
</body>
</html>
Output:
Email Link with Predefined CC and BCC
Share your thoughts in the comments
Please Login to comment...