Anan328
Anan328

Reputation: 21

How to send an email with subject in HTML form

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?

Upvotes: 0

Views: 3397

Answers (2)

Learning
Learning

Reputation: 20001

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:[email protected]?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:[email protected][email protected], [email protected], [email protected]&[email protected]&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:[email protected]">Email Us</a></p>
<h2>Adding a subject</h2>
<p><a href="mailto:[email protected]?subject=Mail from Our Site">Email Us</a></p>
<h2>Adding CC and BCC</h2>
<p><a href="mailto:[email protected][email protected], [email protected], [email protected]&[email protected]&subject=Big%20News">Email Us</a></p>
<h2>Adding body text</h2>
<p><a href="mailto:[email protected][email protected], [email protected], [email protected]&[email protected]&subject=Big%20News&body=Body-goes-here">Email Us</a></p>

More details here

Upvotes: 0

Danylo Halaiko
Danylo Halaiko

Reputation: 145

<a href="mailto:[email protected]?subject=Testing out mailto!">First Example</a>

More look here

Upvotes: 3

Related Questions