How to send email from JavaScript HTML using mailto


Here is a simple example to send an email using JavaScript - mailto. You can use this code with any control (example - button) and even any event (example - onclick).

This code will invoke the user's default email client with the required parameters pre-filled (like email address, subject, message body) and user just needs to click send in order to send the email.

Note - It is not possible to directly send email from JavaScript, you can only invoke/open the default email client.

Code Type: Specify only Email ID
window.open('mailto:useremail@domain.com');
Code Type : Specify multiple Email ID (separate id's by comma(,) or semi-colon(;) )
window.open('mailto:useremail1@domain.com,useremail2@domain.com');
Code Type: Specify Email ID, Subject, Body
window.open('mailto:useremail@domain.com?subject=This is the email subject&body=This is the email body');
Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap