View Single Post
  #5 (permalink)  
Old 10-26-05, 07:02 AM
toth toth is offline
Newbie Coder
 
Join Date: Oct 2005
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
What kind of mailing script are you using. CDONTS, CDOSYS, JMAIL or ASPMAIL?? Are you also working with a database?

Here is a CDONTS sample with a few options:

Your mail form page, I called it MyMail.asp

HTML Code:
<form action="cdonts_form.asp" method="post" name="MyForm" id="MyForm">
<table width="500" border="1" cellspacing="1" cellpadding="2">
<tr>
<td width="135"><strong>First Name</strong></td>
<td width="348"><input name="firstname" type="text" id="firstname" size="30"></td>
</tr>
<tr>
<td><strong>Last Name </strong></td>
<td><input name="lastname" type="text" id="lastname" size="30"></td>
</tr>
<tr>
<td><strong>Email Address </strong></td>
<td><input name="email" type="text" id="email" size="30"></td>
</tr>
<tr>
<td><strong>Sex</strong></td>
<td>Male 
<input name="sex" type="radio" value="Male" checked> 
| Female 
<input name="sex" type="radio" value="Female"></td>
</tr>
<tr>
<td><strong>Colours Required </strong></td>
<td>Red 
<input name="colour1" type="checkbox" id="colour1" value="Red">
| Blue 
<input name="colour2" type="checkbox" id="colour2" value="Blue "> 
| Green 
<input name="colour3" type="checkbox" id="colour3" value="Green"></td>
</tr>
<tr>
<td><strong>Comments</strong></td>
<td><textarea name="comments" cols="28" rows="6" wrap="VIRTUAL" id="comments"></textarea></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="submit" name="Submit" value="Send">
</div></td>
</tr>
</table>
</form>
and the ASP mail script, I called it cdonts_form.asp:

ASP Code:
  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
  2. <%
  3. 'First lets Dim all the variables we need
  4. Dim MyMail
  5. Dim MyBody
  6. Dim MyEmail
  7. Dim MyFirstname
  8. Dim MyLastname
  9. Dim MySex
  10. Dim MyColour1
  11. Dim MyColour2
  12. Dim MyColour3
  13. Dim MyComments
  14. 'Now lets get some values for the variables from the form
  15. MyEmail = Request.Form("email")
  16. MyFirstname = Request.Form("firstname")
  17. MyLastname = Request.Form("lastname")
  18. MySex = Request.Form("sex")
  19. MyColour1 = Request.Form("colour1")
  20. MyColour2 = Request.Form("colour2")
  21. MyColour3 = Request.Form("colour3")
  22. MyComments = Request.Form("comments")
  23.  
  24. 'Now lets build the body of the email from the data in the form
  25. MyBody = "First Name: "& MyFirstName & vbcrlf
  26. MyBody = MyBody & "Last Name: "& MyLastName & vbcrlf
  27. MyBody = MyBody & "Email: "& MyEmail & vbcrlf
  28. MyBody = MyBody & "Sex: "& MySex & vbcrlf & vbcrlf
  29. MyBody = MyBody & "Colour 1: "& MyColour1 & vbcrlf
  30. MyBody = MyBody & "Colour 2: "& MyColour2 & vbcrlf
  31. MyBody = MyBody & "Colour 3: "& MyColour3 & vbcrlf & vbcrlf
  32. MyBody = MyBody & "Comments:" & vbcrlf
  33. MyBody = MyBody & MyComments
  34. 'Now lets put the variables and other information we need into the mailing script
  35. Set MyMail = Server.CreateObject ("CDONTS.NewMail")
  36. MyMail.From = MyEmail
  37. MyMail.To = "You@YourEmailAddress.co.uk"
  38. MyMail.Subject = "Test email using CDONTS"
  39. MyMail.Body = MyBody
  40. MyMail.Send
  41. set MyMail=nothing
  42. Response.Write("Your e-mail has been sent")
  43. %>

greetz, toth

Last edited by UnrealEd; 03-26-07 at 07:48 AM. Reason: please use the correct code syntax highlighters
Reply With Quote