JavaScript mailto: with subject and body – [Solution]

In this tutorial we are going to see how to write a javascript mailto function so that both the subject and body will be Pre-filled?

Many of us might have used mailto function just like below (passing only the mail id):

mailto: someone@example.com

But there are other parameters also you can send it along with that, those are:

1. cc
2. bcc
3. subject
4. body

And one more important thing, you can also send to multiple recipients (see the below example):

mailto: someone1@example.com, sometwo@example.com

Now lets form the entire structure including all the above parameters

 

Make sure you have encoded the text in Subject line and Body. You can see there is a %20 between texts in subject and body right?. Its nothing but space between the texts.

For your convenience, I have given an example code. Just copy and paste and have a try:

Thanks.

Add a Comment

Your email address will not be published. Required fields are marked *