SitePoint Sponsor |
|
User Tag List
Results 1 to 4 of 4
-
Oct 17, 2010, 18:01 #1
- Join Date
- Oct 2010
- Posts
- 1
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
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:
Code:<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Contact - Executive Project Management</title> </head> <body> <% ' Website Contact Form Generator ' http://www.tele-pro.co.uk/scripts/contact_form/ ' This script is free to use as long as you ' retain the credit link ' declare variables Dim EmailFrom Dim EmailTo Dim Subject Dim Name Dim Company Dim Title Dim Telephone Dim Mobile Dim Email Dim Referral Dim Enquiry ' get posted data into variables EmailFrom = Trim(Request.Form("EmailFrom")) EmailTo = "enquiry@execpm.com.au" 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")) ' validation Dim validationOK validationOK=true 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 Dim Body 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 Dim mail Set mail = Server.CreateObject("CDO.Message") mail.To = EmailTo mail.From = EmailFrom mail.Subject = Subject mail.TextBody = Body mail.Send if validationOK = true then response.redirect "ok.html" 'your redirect page goes here' end if %> </body> </html>
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
-
Oct 18, 2010, 02:27 #2
- Join Date
- Oct 2002
- Location
- Scotland
- Posts
- 3,631
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
That seems a little - incomplete. (There is no Configuration defined). Check out these links for more info:
http://classicasp.aspfaq.com/email/h...-with-cdo.html
http://www.asp101.com/articles/john/...ay/default.asp
-
Oct 23, 2010, 23:43 #3
- Join Date
- Oct 2001
- Location
- Vancouver BC Canada
- Posts
- 2,037
- Mentioned
- 5 Post(s)
- Tagged
- 0 Thread(s)
Yeah, I noticed things have changed a bit over the last few years, probably for more secure SMTP but none-the-less it can get confusing when things work on one server and not another.
For CDO on the server I always add this line at the very top of the script:
Code:<!--METADATA TYPE="typelib" UUID="CD000000-8B95-11D1-82DB-00C04FB1625D" NAME="CDO for Windows 2000 Library" -->
My forms look a bit like this:
Code:Dim ObjMail Set ObjMail = Server.CreateObject("CDO.Message") 'Configuration: sch = "http://schemas.microsoft.com/cdo/configuration/" Set objConfig = CreateObject("CDO.Configuration") With objConfig.Fields .Item(sch & "sendusing") = 2 .Item(sch & "smtpserver") = "domain-name or ip-address" .update End With Set objMail.Configuration = objConfig objMail.From = "some-email-address@some-domain.com" objMail.To = "email@somewhere.com" objMail.CC = "cc-email@somewhere.com" objMail.Subject = "Your subject" mailbody = "<p>This is HTML, so put in your tags and apply fonts, etc... so your message looks good.</p>" objMail.HTMLBody = mailbody objMail.Send Set objMail = Nothing
Andrew Wasson | www.lunadesign.org
Principal / Internet Development
-
Oct 24, 2010, 10:48 #4
- Join Date
- Jun 2007
- Posts
- 691
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Have you verified that "EmailFrom" and "EmailTo" actually have values ?
The sample code uses these variable names but do they match the names of the corresponding fields in your form ?
Bookmarks