I know how to send an email in html form using action mailto: in form element. But this sends an email without the subject, How send an email with subject?
-
2https://www.computerhope.com/issues/ch000056.htm#:~:text=If%20you%20want%20to%20add,similar%20to%20the%20example%20below.&text=You%20can%20also%20add%20body,shown%20in%20the%20example%20below. – ShanieMoonlight Feb 07 '21 at 17:57
-
1Duplicate: https://stackoverflow.com/questions/4782068/can-i-set-subject-content-of-email-using-mailto – Seth B Feb 07 '21 at 20:47
2 Answers
<a href="mailto:test@example.com?subject=Testing out mailto!">First Example</a>
More look here

- 135
- 1
- 7
Its not clear in your question whether you want to automatically add when user click on the link or your code to send email is not email with subject.. You need to explain it more with code example.
I am assuming you are asking for link this case you can use below code
<a href="mailto:someone@yoursite.com?subject=Mail from Our Site">Email Us</a>
Once use will click on link it will open link in default email client eg. outlook with email & subject line.
You can add cc, bcc and even body text in such way below are some examples
Adding CC and BCC
Open default mail program, create new message with the TO, SUBJECT, CC, and BCC field already filled out. Essentially we are adding the parameters cc and bcc to the href value.
Also note that you add multiple values to CC and BCC by comma separating them.
<a href="mailto:someone@yoursite.com?cc=someoneelse@theirsite.com, another@thatsite.com, me@mysite.com&bcc=lastperson@theirsite.com&subject=Big%20News">Email Us</a>
Adding body text
Just add the body parameter into the ever-growing list of parameters we are using.
<h2>Basic</h2>
<p><a href="mailto:someone@yoursite.com">Email Us</a></p>
<h2>Adding a subject</h2>
<p><a href="mailto:someone@yoursite.com?subject=Mail from Our Site">Email Us</a></p>
<h2>Adding CC and BCC</h2>
<p><a href="mailto:someone@yoursite.com?cc=someoneelse@theirsite.com, another@thatsite.com, me@mysite.com&bcc=lastperson@theirsite.com&subject=Big%20News">Email Us</a></p>
<h2>Adding body text</h2>
<p><a href="mailto:someone@yoursite.com?cc=someoneelse@theirsite.com, another@thatsite.com, me@mysite.com&bcc=lastperson@theirsite.com&subject=Big%20News&body=Body-goes-here">Email Us</a></p>
More details here

- 19,469
- 39
- 180
- 373