Hassles with ASP Contact form using CDO.Message
Having never had to use ASP for a contact form before, i'm struggling. Hopefully some kind soul will be able to give me some advice on the following:
I found code here in these forums, and modified it to suit my form. Here is the result:
However when I tried to submit the form I get the following error:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Contact - Executive Project Management</title>
' Website Contact Form Generator
' This script is free to use as long as you
' retain the credit link
' declare variables
' get posted data into variables
EmailFrom = Trim(Request.Form("EmailFrom"))
EmailTo = "email@example.com"
Subject = "Web Enquiry"
Name = Trim(Request.Form("Name"))
Company = Trim(Request.Form("Company"))
Title = Trim(Request.Form("Title"))
Telephone = Trim(Request.Form("Telephone"))
Mobile = Trim(Request.Form("Mobile"))
Email = Trim(Request.Form("Email"))
Referral = Trim(Request.Form("Referral"))
Enquiry = Trim(Request.Form("Enquiry"))
If (Trim(Name)="") Then validationOK=false
If (Trim(Company)="") Then validationOK=false
If (Trim(Email)="") Then validationOK=false
If (validationOK=false) Then Response.Redirect("error.html?" & EmailFrom)
' prepare email body text
Body = Body & "Name: " & Name & VbCrLf
Body = Body & "Company: " & Company & VbCrLf
Body = Body & "Title: " & Title & VbCrLf
Body = Body & "Telephone: " & Telephone & VbCrLf
Body = Body & "Mobile: " & Mobile & VbCrLf
Body = Body & "Email: " & Email & VbCrLf
Body = Body & "Referral: " & Referral & VbCrLf
Body = Body & "Enquiry: " & Enquiry & VbCrLf
' send email
Set mail = Server.CreateObject("CDO.Message")
mail.To = EmailTo
mail.From = EmailFrom
mail.Subject = Subject
mail.TextBody = Body
if validationOK = true then
response.redirect "ok.html" 'your redirect page goes here'
I've tried going through these forums and searching using google but i just feel like i'm going round in circles. Can anyone point me in the right direction for what i need to do to get this happening?
CDO.Message.1 error '8004020d'
At least one of the From or Sender fields is required, and neither was found.
/contact.asp, line 70
Thanks in advance