Petrolhead
Technical User
- Mar 13, 2009
- 27
Hi there,
I'm wondering if anoyne can help me I've designed an HTML contact form and I'm tryign to write a script to get the form to e-mail the information to me.
I'm better at VBA than ASP so I was wondering if anyone could have a look at the script for me.
The code for the form is as follows:
I'm wondering if anoyne can help me I've designed an HTML contact form and I'm tryign to write a script to get the form to e-mail the information to me.
I'm better at VBA than ASP so I was wondering if anyone could have a look at the script for me.
Code:
' declare variables
Dim EmailTo
Dim Subject
Dim Name
Dim Subject
Dim E-MailAddress
Dim Message
' get posted data into variables
EmailTo = "tirvine24@gmail.com"
Subject = Trim(Request.Form("Subject"))
Name = Trim(Request.Form("Name"))
E-MailAddress = Trim(Request.Form("Email"))
Message = Trim(Request.Form("Message"))
' validation
Dim validationOK
validationOK=true
If (Trim(Name)="") Then validationOK=false
If (Trim(Subject)="") Then validationOK=false
If (Trim(Email)="") Then validationOK=false
If (Trim(Message)="") Then validationOK=false
If (validationOK=false) Then Response.Redirect("error.htm")
' prepare email body text
Dim Body
Body = Body & "Name: " & Name & VbCrLf
Body = Body & "Subject: " & Subject & VbCrLf
Body = Body & "E-MailAddress: " & E-MailAddress & VbCrLf
Body = Body & "Message: " & Message & VbCrLf
' send email
Dim mail
Set mail = Server.CreateObject("CDONTS.NewMail")
mail.To = EmailTo
mail.Subject = Subject
mail.Body = Body
mail.Send
' redirect to success page
Response.Redirect("contact-info-thank-you.htm")
The code for the form is as follows:
Code:
<div id="content">
<!-- Begin Main Page Content -->
<!-- main content section -->
<h1>
Contact
</h1>
<form method="POST" action="contact.asp">
<table width="90%" cellspacing=5 cellpadding=5>
<tr>
<td align=left><b>Your name</b><br>
<input type="text" name="name" size=30 maxlength=50 id="name"></td>
</tr>
<tr>
<td align=left><b>Your email address</b><br>
<input type="text" name="email" size=30 maxlength=255 id="email"></td>
</tr>
<tr>
<td align=left><b>Message type</b><br>
<select name="subject[]" id="subject[]" >
<option value="Comment[]" selected>Feedback
<option value="Suggestion[]">Suggestion
<option value="Problem or typo[]">Problem or typo report
<option value="Other[]">Other
</select>
</td></tr>
<tr>
<td align=left><b>Your message</b><br>
<textarea cols="50" rows="5" name="Message"></textarea></td>
</tr>
<tr><td align=center colspan=2><input type="Submit" value="Submit Message"></td></tr>
</table>
</form>
<br>
</div> <!-- content -->