Open In App

How to Create a Link to Send Email in HTML ?

Last Updated : 04 Apr, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

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-subject

Email Link with Predefined Subject

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:

link-to-email-with-cc-bcc

Email Link with Predefined CC and BCC


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads