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'');
Code Type : Specify multiple Email ID (separate id's by comma(,) or semi-colon(;) )',');
Code Type: Specify Email ID, Subject, Body' is the email subject&body=This is the email body');
Try Out Code2care Dev Tools:


Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and software developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include learnings, tutorials, trouble-shooting steps, video tutorials, code snippets, how-to, blogs, articles, etc.

🎉 We are celebrating the 10th years of Code2care! Thank you for all your support!

We strongly support Gender Equality & Diversity.