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:[email protected]');
Code Type : Specify multiple Email ID (separate id's by comma(,) or semi-colon(;) )
window.open('mailto:[email protected],[email protected]');
Code Type: Specify Email ID, Subject, Body
window.open('mailto:[email protected]?subject=This is the email subject&body=This is the email body');