.asp contact form

Soldato
Joined
2 Oct 2004
Posts
4,362
Location
N.W London
This is my .asp code for a contact page:


<%
' declare variables
Dim EmailFrom
Dim EmailTo
Dim Subject
Dim Name
Dim Mobile
Dim Date
Dim Time
Dim Pickup
Dim Dropoff
Dim Vehicle
Dim Flight_Number
Dim Pax
Dim Luggages
Dim Comments


' get posted data into variables
EmailFrom = Trim(Request.Form("EmailFrom"))
EmailTo = ""my email address"
Subject = "website enquiry"
Name = Trim(Request.Form("Name"))
Mobile = Trim(Request.Form("Mobile"))
Date = Trim(Request.Form("Date"))
Time = Trim(Request.Form("Time"))
Pickup = Trim(Request.Form("Pickup"))
Dropoff = Trim(Request.Form("Dropoff"))
Vehicle = Trim(Request.Form("Vehicle"))
Flight_Number = Trim(Request.Form("Flight_Number"))
Pax = Trim(Request.Form("Pax"))
Luggages = Trim(Request.Form("Luggages"))
Comments = Trim(Request.Form("Comments"))

' validation
Dim validationOK
validationOK=true
If (Trim(EmailFrom)="") 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 & "Mobile: " & Mobile & VbCrLf
Body = Body & "Date: " & Date & VbCrLf
Body = Body & "Time: " & Time & VbCrLf
Body = Body & "Pickup: " & Pickup & VbCrLf
Body = Body & "Dropoff: " & Dropoff & VbCrLf
Body = Body & "Vehicle: " & Vehicle & VbCrLf
Body = Body & "Flight_Number: " & Flight_Number & VbCrLf
Body = Body & "Pax: " & Pax & VbCrLf
Body = Body & "Luggages: " & Luggages & VbCrLf
Body = Body & "Comments: " & Comments & VbCrLf

' send email
Dim mail
Set mail = Server.CreateObject("CDONTS.NewMail")
mail.To = EmailTo
mail.From = EmailFrom
mail.Subject = Subject
mail.Body = Body
mail.Send

' redirect to success page
Response.Redirect("thankyou.html" & EmailFrom)
%>

when the user presses submit button they see this error:

Server object error 'ASP 0177 : 800401f3'

Server.CreateObject Failed

/contactusprocess.asp, line 248

800401f3

why is that?

how can I fix it?

please help

thanks in advance
 
Last edited:
thank you so much

as I know very little about .asp even when I google these things I dont understand them

I know i am close to completing this is there any chance you can hold my hand as it were and tell me what I need to replace this with so that the form work:

' send email
Dim mail
Set mail = Server.CreateObject("CDONTS.NewMail")
mail.To = EmailTo
mail.From = EmailFrom
mail.Subject = Subject
mail.Body = Body
mail.Send

thank you
 
thank you for your reply

2 lil questions:

like this?

myMail.TextBody="Body"

and


what should I replace these two fields with?

like where does my email address go and what part of this code picks up the email addy that the user inputs?

thank you for your help

I presume line: 248 in your original script was:
Set mail = Server.CreateObject("CDONTS.NewMail")

yes thats true it was until you advised me to change it
 
Last edited:
I changed the code to:

Set myMail=CreateObject("CDO.Message")
myMail.Subject="Sending email with CDO"
myMail.From="[email protected]"
myMail.To="[email protected]"
myMail.TextBody="Body"
myMail.Send
set myMail=nothing

and now recieve this error:
Server object error 'ASP 0177 : 800401f3'

Server.CreateObject Failed

/contactusprocess.asp, line 249

800401f3

line 249 is this:

myMail.Subject="Sending email with CDO"
 
I now added a little extra code so it looks like this:

Set myMail=CreateObject("CDO.Message")
myMail.Subject="Sending email with CDO"
myMail.From="[email protected]"
myMail.To="[email protected]"
myMail.TextBody="Body"
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
'Name or IP of remote SMTP server
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver")="smtp.server.com"
'Server port
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=25
myMail.Configuration.Fields.Update
myMail.Send
set myMail=nothing

I now recieve this error:

error '8004020f'

/contactusprocess.asp, line 262

line 262 is this:

myMail.Send

I reckon its because these two lines are not configured , what should I input there:


am so close can feel it

please help
 
it is windows hosting yep

this is going on a live website yep

2) In you case, like this:

Quote:
myMail.From=EmailFrom
myMail.To=EmailTo

so am I putting an email address here or does the code automatically pick it up?

can I send you both files for you to correct? please am so close, its something so small
 
I am uploading the files to my host and then go to the website online and complete the form and get that error now:

I now recieve this error:


error '8004020f'

/contactusprocess.asp, line 262
line 262 is this:


myMail.Send

I reckon its because these two lines are not configured , what should I input there:



the whole code currently looks like this:

Set myMail=CreateObject("CDO.Message")
myMail.Subject="Sending email with CDO"
myMail.From="[email protected]"
myMail.To="[email protected]"
myMail.TextBody=Body
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
'Name or IP of remote SMTP server
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver")="smtp.server.com"
'Server port
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=25
myMail.Configuration.Fields.Update
myMail.Send <----------------LINE 262
set myMail=nothing

still get that line 262 error
 
Last edited:
Back
Top Bottom