Email Subject and Body Set By Form

[Total: 0    Average: 0/5]

This shows how to set up a HREF based upon form fields. This HREF sends an email via GET and passes the desired subject body and To: fields.

Head Code:

<SCRIPT type=text/javascript>
// note: &cc=carbonCopyEmailAddress works too!

function mailsome1(){
  who=document.exf1.who.value;
  sub1=document.exf1.sub1.value;
  sub2=document.exf1.sub2.value;
  body1=document.exf1.bod1.value;
  body2=document.exf1.bod2.value;
  parent.location.href="mailto:"+who+"?subject="+sub1+","+sub2+"&body="+body1+","+body2;
}
</SCRIPT>
</head>

Body Code:

<CENTER>
<FORM name=exf1>
<table>
<tr><td align=right>To: <input name=who type=text value="test@somesite.com"><BR></td></tr>
<tr><td align=right>Subject Part 1: <input name=sub1 type=text value="subject1"><BR></td></tr>
<tr><td align=right>Subject Part 2: <input name=sub2 type=text value="subject2"><BR></td></tr>
<tr><td align=right>Body Part 1: <input name=bod1 type=text value="body1"><BR></td></tr>
<tr><td align=right>Body Part 2: <input name=bod2 type=text value="body2"><BR></td></tr>
<tr><td align=center><input type="button" value="Send E-Mail" onClick="mailsome1()"></td></tr>
</table>
</FORM>
</CENTER>

Times Viewed: 0

Leave a Reply

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