Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I set up a form to send form results in an e-mail message?

Status
Not open for further replies.

fmasin

Technical User
May 3, 2002
163
GB
Hi,

I am building a simple website for my company using ASP codes. I have designed a few forms for clients to fill over the internet and submit. However, as I’m quite new to this web staff – I’m finding it difficult to get the appropriate code to accomplish this task. All I need to know is how they can submit the information collected on the forms.




Thanks and regards,

Francis
 
DNG,

Many thanks for your link - However, the code simply looks too complicated for me to understand.

Please, an example of the form is pasted below. Where exactly would I used the few relevant bits of your code.

Thanks again.

===================================================

<%@ LANGUAGE="VBSCRIPT" %>

<html>
<head>

<title>Conveyancingfrm - OCHsolicitors.co.uk</title>
<link rel="stylesheet" type="text/css" href="och.css">
</head>
<body bgcolor="#888fff"><br /><br />
<br align="center">

<table border=0 cellpadding=0 cellspacing=0 width="80%" align="center">
<tr>
<td>
<div align="top">
<b>
<div class="logo"><img src="file:///C:\Documents and Settings\Owner\My Documents\Irene\Final year Project\Project system\Images\OCH Logo.gif" align="right" alt="" width="200" height="60" /></div>
</b>
</div></table><br/><br/>
<div class="items"align="center"><i>

<a href="Index.asp">Home</a>&nbsp;&nbsp;&nbsp;&nbsp;
<a href="Index.asp">Services</a>&nbsp;&nbsp;&nbsp;
<a href="Aboutus.asp">About Us</a>&nbsp;&nbsp;&nbsp;
<a href="Contact.asp">Contact Us</a>&nbsp;&nbsp;&nbsp;
<a href="Registration.asp">Registration</a>&nbsp;&nbsp;&nbsp;
<a href="Links.asp">Links</a>&nbsp;&nbsp;&nbsp;
<a href="Comments.asp">Comments</a>&nbsp;&nbsp;&nbsp;
<a href="javascript:history.back()"> Back</a></i>
</div><br/><br/>

<table summary="Home | OCH- Solicitors" width="100%" border="0" cellspacing="0" cellpadding="0">
<col width="210" />
<col width="510" />
<tr valign="top">
<td>
<div class="col1">
<h2 class="heading"align="center"><span>Conveyancing quotation <br />requests </span></h2><br /><br /><br />
<p class="formintro">Please complete this form in full and click on the box at the bottom of the page to send the e-mail to us.<br />We will respond to you promptly.</p>
</div>
</td>
<td>
<div class="col2">
<form action="--WEBBOT-SELF--" method="POST" name="Conveyancing form">
<!--webbot bot="SaveResults" u-file="C:\Documents and Settings\Owner\Desktop\Convenyancing Details" s-format="HTML/BR" s-label-fields="TRUE" b-reverse-chronology="FALSE" s-email-format="TEXT/PRE" s-email-address="francis@masinde.freeserve.co.uk" b-email-label-fields="TRUE" b-email-replyto-from-field="TRUE" s-email-replyto="km254@gre.ac.uk" b-email-subject-from-field="FALSE" s-email-subject="Client Details" s-builtin-fields --><input type="hidden" name="category" value="conveyancing" /><table class="form" summary="" width="522" border="0" cellspacing="1" cellpadding="8" bgcolor="#003399">
<col width="60%" />
<col />
<tr valign="top">
<td bgcolor="white">Name<br />
<input class="input" type="text" name="form[name]" size="20" /></td>
<td bgcolor="white">Home telephone<br />
<input class="input" type="text" name="form[ph_home]" size="20" /></td>
</tr>
<tr valign="top">
<td rowspan="2" bgcolor="white">Address<br /><textarea class="input" name="form[address]" rows="5" cols="45"></textarea></td>
<td bgcolor="white">Work<br />
<input class="input" type="text" name="form[ph_work]" size="20" /></td>
</tr>
<tr valign="top">
<td bgcolor="white">Mobile<br />
<input class="input" type="text" name="form[ph_mobile]" size="20" /></td>
</tr>
<tr valign="top">
<td bgcolor="white">Postcode<br />
<input class="input" type="text" name="form[postcode]" size="20" /></td>
<td bgcolor="white">E-mail<br />
<input class="input" type="text" name="form" size="20" /></td>
</tr>
<tr valign="top">
<td bgcolor="white">Your preferred method of contact<br />
<input class="input" type="text" name="form[contact_method]" size="20" /></td>
<td bgcolor="white">Are you an existing client?<br />Yes
<input type="checkbox" name="form[existing_client]" value="ON" />&nbsp;&nbsp;No&nbsp;&nbsp;<input type="checkbox" name="form[existing_client]" value="ON" /></td>
</tr>
<tr valign="top">
<td colspan="2" bgcolor="white">Transaction details<br />Purchase <input type="checkbox" name="form[transaction]" value="Yes" />&nbsp;&nbsp;Sale <input type="checkbox" name="form[transaction]" value="Yes" />&nbsp;&nbsp;Purchase and sale <input type="checkbox" name="form[transaction]" value="Yes" />&nbsp;&nbsp;Re-mortgage <input type="checkbox" name="form[transaction]" value="Yes" /></td>
</tr>
<tr valign="top">
<td bgcolor="white">Recommended by<br />
<input class="input" type="text" name="form[recommended_by]" size="20" /></td>
<td bgcolor="white">Estate agents used<br />
<input class="input" type="text" name="form[estate_agents]" size="20" /></td>
</tr>
<tr valign="top">
<td bgcolor="white"><b>Sale:</b> address of property<br /><textarea class="input" name="form[sale_property_address]" rows="4" cols="45"></textarea></td>
<td bgcolor="white">Is the property<br />Freehold
<input type="checkbox" name="form[sale_property_title]" value="ON" />&nbsp;&nbsp;Leasehold&nbsp;&nbsp;<input type="checkbox" name="form[sale_property_title]" value="ON" /></td>
</tr>
<tr valign="top">
<td bgcolor="white">Postcode<br />
<input class="input" type="text" name="form[postcode]" size="20" /></td>
<td bgcolor="white">Sale price £<br />
<input class="input" type="text" name="form[sale_property_price]" size="20" /></td>
</tr>
<tr valign="top">
<td bgcolor="white"><b>Purchase</b>: address of property<br /><textarea class="input" name="form[sale_property_address]" rows="4" cols="45"></textarea></td>
<td bgcolor="white">Is the property<br />Freehold
<input type="checkbox" name="form[sale_property_title]" value="ON" />&nbsp;&nbsp;Leasehold&nbsp;&nbsp;<input type="checkbox" name="form[sale_property_title]" value="ON" /></td>
</tr>
<tr valign="top">
<td bgcolor="white">Postcode<br />
<input class="input" type="text" name="form[postcode]" size="20" /></td>
<td bgcolor="white">Purchase price £<br />
<input class="input" type="text" name="form[sale_property_price]" size="20" /></td>
</tr>
<tr valign="top">
<td bgcolor="white"><b>Re-mortgage:</b> address of property<br /><textarea class="input" name="form[sale_property_address]" rows="4" cols="45"></textarea></td>
<td bgcolor="white">Is the property<br />Freehold
<input type="checkbox" name="form[sale_property_title]" value="ON" />&nbsp;&nbsp;Leasehold&nbsp;&nbsp;<input type="checkbox" name="form[sale_property_title]" value="ON" /></td>
</tr>
<tr valign="top">
<td bgcolor="white">Postcode<br />
<input class="input" type="text" name="form[postcode]" size="20" /></td>
<td bgcolor="white">Re-mortgage price £<br />
<input class="input" type="text" name="form[sale_property_price]" size="20" /></td>
</tr>
<tr valign="top">
<td bgcolor="white">New lender<br />
<input class="input" type="text" name="form[new_lender]" size="20" /></td>
<td bgcolor="white">Existing lender<br />
<input class="input" type="text" name="form[existing_lender]" size="20" /></td>
</tr>
<tr>
<td colspan="2" bgcolor="white"> <br /><p>
<strong>Send </strong>
<button name="Send" style="width: 84; height: 24" type="Submit"><strong>Email</strong></button>&nbsp;&nbsp;
<button name="Clear" style="width: 84; height: 24" type="reset"><strong>Clear Form</strong></button>&nbsp;&nbsp;
<button name="Home" style="width: 84; height: 24"><a href="index.asp"><strong>Home</a></strong></button>&nbsp;&nbsp; <button name="B3" style="width: 84; height: 24">
<a href="javascript:history.back )"><strong>Back</a></strong></button>
</td></tr></table>
</p>
</form>



</td>
</tr>
</table>
</div>
</td>
<td>&nbsp;</td>
</tr>
</table>
</body>

</html>
=====================================================

Thanks and regards,

Francis
 
Here is an example of an asp page that uses CDONTS to send an email. The page reads the submitted form fields to get the info for the mail TO, FROM, CC, Subject and Body, then sends it to CDONTS to email.
CDOSYS is a newer component replacing CDONTS and works very similarly. You have to find out if you have an email component on your server first. This just gives you an example of how it is done.

Code:
<%
  mailFrom=request.form("MailFrom")
  mailTo = request.form("MailTo")
  mailSubject = request.form("MailSubject")
  mailbody = request.form("strOut")
  mailCC = request.form("MailToCC")
 
  Set objMail = Server.CreateObject("CDONTS.NewMail")
  objMail.BodyFormat = 0 ' If you want to send as plan text remove this line, otherwise it sends as HTML.
  objMail.MailFormat = 0 ' If you want to send as plan text remove this line, otherwise it sends as HTML.
  objMail.From =  mailFrom
  objMail.To = mailTo
  objMail.CC = mailCC
  objMail.Subject = mailSubject
  objMail.Body = mailbody
  objMail.Send 
  Set objMail = Nothing
%>

The above code relies on you providing those fields.
The body of the message will be in one long string and you can format it with HTML tags.
For now I suggest you set it to just send text and test emailing, then get fancy once you have it working.


Paranoid? ME?? WHO WANTS TO KNOW????
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top