ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 8th, 2003, 08:57 AM
sneezy sneezy is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: London
Posts: 8 sneezy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Talking Contact Form (Newbie)

Hi doin a simple contact form, have three files contact_form.asp, contact_form1.asp which as my code in it and a thanks.asp. My code looks like this

<% @language="VBSCRIPT" %>
<%
Dim myMail, myBody
myBody ="Name: "& request.form("name") & vbcrlf & "E-Mail: " & request.form("email") & vbcrlf & "Message: "& vbcrlf & request.form ("message")
Set myMail = Server.CreateObject ("CDONTS.NewMail")
myMail.From = request.form("email")
myMail.To = "sarah.adams@mehdiward.com"
myMail.Subject = "Customer Contact"
myMail.Body = myBody
myMail.Send
set myMail=nothing

Response.Redirect("contact_thanks.asp")
%>

in my body i have a number of other sections to my form ie age, telephone number. Also a drop down which has female or male in it. Please see url

http://www.mcexecutive.com/test/contact_form.asp

Could anyone tell me how to amend the body.

Many thanks

Reply With Quote
  #2  
Old August 8th, 2003, 09:43 AM
Vlince Vlince is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Canada, Quebec, Montreal
Posts: 410 Vlince User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
I *STRONGLY* urge you to use variables. This will clarify your code thus making everything clearer and pehaps error free )


Now,

<% @language="VBSCRIPT" %>

<%
Dim objMail
Dim myBody
Dim strName
Dim lngAge
Dim strEmail
Dim strHomePhone


'NOTICE the prefix I've been giving, obj, str, lng
'these help me understand what to expect in those variables

'Retrieve the value of your <form>...</form> into variables
strName = Trim(Request.Form("aaa"))
lngAge = Trim(Request.Form("bbb"))
strEmail = Trim(Request.Form("ccc"))
strHomePhone = Trim(Request.Form("ddd"))

'NOTE: change the value of aaa, bbb, ccc, ddd with the proper names you have.
'Also note that if you want, you can add more fields but I didn't
'put them only to keep my example small.

'Now if you wanted, you COULD make some validation
'Example:
If strName = "" Then
....code to do something if the variable is = to ""...
End If

'You are NOT obligated to make a validation, in fact, your validation
'should be done in client side using javascript


'Build the <BODY> of the email:
myBody = strName & "<br>" & _
lngAge & "<br>" & _
".....etc......."


'Let's instantiate the mail object now:
Set objMail = Server.CreateObject ("CDONTS.NewMail")

objMail.From = request.form("email") 'OR use strEmail
objMail.To = "sarah.adams@mehdiward.com"
objMail.Subject = "Customer Contact"
objMail.Body = myBody
objMail.Send

%>

Notice the part 'OR use strEmail instead of making ANOTHER Request.Form ... you ALREADY hold the email address into a variable(strEmail) that's why its nice to keep stuff in variables!


You might also want to use the If NOT IsObject(objMail) Then after you instantiate the mail object just to make sure it is registered...


Hope this helps!
Sincerely

Vlince

Reply With Quote
  #3  
Old August 8th, 2003, 10:09 AM
sneezy sneezy is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: London
Posts: 8 sneezy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Sorry if I'm not getting this but my code should look like this?

<% @language="VBSCRIPT" %>
<%
Dim objMail
Dim myBody
Dim strName = Trim(Request.Form("name"))
Dim strMorf = Trim(Request.Form("morf"))
Dim lngAge = Trim(Request.Form("age"))
Dim strPresentsalary = Trim(Request.Form("presentsalary"))
Dim strPositionofinterest = Trim(Request.Form("positionofinterest"))
Dim strExpertise = Trim(Request.Form("expertise"))
Dim strLocationnow = Trim(Request.Form("locationnow"))
Dim strLocationwanted = Trim(Request.Form("locationwanted"))
Dim strHomephone = Trim(Request.Form("homephone"))
Dim strMobile = Trim(Request.Form("mobile"))
Dim strWorkphone = Trim(Request.Form("workphone"))
Dim strEmail = Trim(Request.Form("email"))
Dim strMessage = Trim(Request.Form("message"))
Dim strInfo = Trim(Request.Form("info"))
Set objMail = Server.CreateObject ("CDONTS.NewMail")
objMail.From = request.form("email")
objMail.To = "sarah.adams@mehdiward.com"
objMail.Subject = "Customer Contact"
objMail.Body = myBody
objMail.Send

Response.Redirect("contact_thanks.asp")
%>

Many thanks

Reply With Quote
  #4  
Old August 8th, 2003, 10:15 AM
Vlince Vlince is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Canada, Quebec, Montreal
Posts: 410 Vlince User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Yes it should look like that IF THAT IS WHAT YOU WANT of course!

There is just one thing missing...


<% @language="VBSCRIPT" %>
<%
Dim objMail
Dim myBody
Dim strName = Trim(Request.Form("name"))
Dim strMorf = Trim(Request.Form("morf"))
Dim lngAge = Trim(Request.Form("age"))
Dim strPresentsalary = Trim(Request.Form("presentsalary"))
Dim strPositionofinterest = Trim(Request.Form("positionofinterest"))
Dim strExpertise = Trim(Request.Form("expertise"))
Dim strLocationnow = Trim(Request.Form("locationnow"))
Dim strLocationwanted = Trim(Request.Form("locationwanted"))
Dim strHomephone = Trim(Request.Form("homephone"))
Dim strMobile = Trim(Request.Form("mobile"))
Dim strWorkphone = Trim(Request.Form("workphone"))
Dim strEmail = Trim(Request.Form("email"))
Dim strMessage = Trim(Request.Form("message"))
Dim strInfo = Trim(Request.Form("info"))

Set objMail = Server.CreateObject ("CDONTS.NewMail")
objMail.From = request.form("email")
objMail.To = "sarah.adams@mehdiward.com"
objMail.Subject = "Customer Contact"
objMail.Body = myBody
objMail.Send


Set objMail = nothing

Response.Redirect("contact_thanks.asp")
%>

Where do you build/construct the variable myBody ???

I dont see it in your code?

Build the myBody using the OTHER variables something like:

myBody = strName & "<br>" & _
strMorf & "<br>" & _
lngAge & "<br>" & _
"...continue with other variables..."

Hope this helps!
Sincerely

Vlince

Reply With Quote
  #5  
Old August 8th, 2003, 10:49 AM
sneezy sneezy is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: London
Posts: 8 sneezy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
ok how about this!

<% @language="VBSCRIPT" %>
<%
Dim objMail
Dim myBody
Dim strName = Trim(Request.Form("name"))
Dim strMorf = Trim(Request.Form("morf"))
Dim lngAge = Trim(Request.Form("age"))
Dim strPresentsalary = Trim(Request.Form("presentsalary"))
Dim strPositionofinterest = Trim(Request.Form("positionofinterest"))
Dim strExpertise = Trim(Request.Form("expertise"))
Dim strLocationnow = Trim(Request.Form("locationnow"))
Dim strLocationwanted = Trim(Request.Form("locationwanted"))
Dim strHomephone = Trim(Request.Form("homephone"))
Dim strMobile = Trim(Request.Form("mobile"))
Dim strWorkphone = Trim(Request.Form("workphone"))
Dim strEmail = Trim(Request.Form("email"))
Dim strMessage = Trim(Request.Form("message"))
Dim strInfo = Trim(Request.Form("info"))
myBody = strName & "<br>" & _ strMorf & "<br>" & _ lngAge & "<br>" & _ strPresentsalary & "<br>" & _ strPositionofinterest& "<br>" & _ strExpertise & "<br>" & _strLocationnow & "<br>" & _ strLocationwanted & "<br>" & _ strHomephone & "<br>" & _ strMobile & "<br>" & _ strWorkphone & "<br>" & _ strEmail & "<br>" & _ strMessage & "<br>" & _ strInfo & "<br>" & _
Set objMail = Server.CreateObject ("CDONTS.NewMail")
objMail.From = request.form("email")
objMail.To = "sarah.adams@mehdiward.com"
objMail.Subject = "Customer Contact"
objMail.Body = myBody
objMail.Send

Set objMail = nothing

Response.Redirect("contact_thanks.asp")
%>

when i test this it come up with error or my page could of cashed?

Reply With Quote
  #6  
Old August 8th, 2003, 10:56 AM
sneezy sneezy is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: London
Posts: 8 sneezy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
CDONTS.NewMail.1 error '80020009'

501 ASP Service Disabled

/test/contact_post1.asp, line 10


the above error message

Reply With Quote
  #7  
Old August 8th, 2003, 11:01 AM
Vlince Vlince is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Canada, Quebec, Montreal
Posts: 410 Vlince User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
What's line 10 ?

Another thing, you'll get an error(if that's not the one) for NOT finishing the string your building...here look at this:

myBody = strName & "<br>" & _ strMorf & "<br>" & _ lngAge & "<br>" & _ strPresentsalary & "<br>" & _ strPositionofinterest& "<br>" & _ strExpertise & "<br>" & _strLocationnow & "<br>" & _ strLocationwanted & "<br>" & _ strHomephone & "<br>" & _ strMobile & "<br>" & _ strWorkphone & "<br>" & _ strEmail & "<br>" & _ strMessage & "<br>" & _ strInfo & "<br>" & _

look at the bold

It shouldn't be there...should be :
myBody = strName & "<br>" & _ strMorf & "<br>" & _ lngAge & "<br>" & _ strPresentsalary & "<br>" & _ strPositionofinterest& "<br>" & _ strExpertise & "<br>" & _strLocationnow & "<br>" & _ strLocationwanted & "<br>" & _ strHomephone & "<br>" & _ strMobile & "<br>" & _ strWorkphone & "<br>" & _ strEmail & "<br>" & _ strMessage & "<br>" & _ strInfo & "<br>"

Try it now...

Reply With Quote
  #8  
Old August 8th, 2003, 11:14 AM
sneezy sneezy is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: London
Posts: 8 sneezy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
new code

<% @language="VBSCRIPT" %>
<%
Dim objMail
Dim myBody
Dim strName = Trim(Request.Form("name"))
Dim strMorf = Trim(Request.Form("morf"))
Dim lngAge = Trim(Request.Form("age"))
Dim strPresentsalary = Trim(Request.Form("presentsalary"))
Dim strPositionofinterest = Trim(Request.Form("positionofinterest"))
Dim strExpertise = Trim(Request.Form("expertise"))
Dim strLocationnow = Trim(Request.Form("locationnow"))
Dim strLocationwanted = Trim(Request.Form("locationwanted"))
Dim strHomephone = Trim(Request.Form("homephone"))
Dim strMobile = Trim(Request.Form("mobile"))
Dim strWorkphone = Trim(Request.Form("workphone"))
Dim strEmail = Trim(Request.Form("email"))
Dim strMessage = Trim(Request.Form("message"))
Dim strInfo = Trim(Request.Form("info"))
myBody = strName & "<br>" & _ strMorf & "<br>" & _ lngAge & "<br>" & _ strPresentsalary & "<br>" & _ strPositionofinterest& "<br>" & _ strExpertise & "<br>" & _strLocationnow & "<br>" & _ strLocationwanted & "<br>" & _ strHomephone & "<br>" & _ strMobile & "<br>" & _ strWorkphone & "<br>" & _ strEmail & "<br>" & _ strMessage & "<br>" & _ strInfo & "<br>"
Set objMail = Server.CreateObject ("CDONTS.NewMail")
objMail.From = request.form("email")
objMail.To = "sarah.adams@mehdiward.com"
objMail.Subject = "Customer Contact"
objMail.Body = myBody
objMail.Send

Set objMail = nothing

Response.Redirect("contact_thanks.asp")
%>

same error message. Anything else that could be wrong?

Reply With Quote
  #9  
Old August 8th, 2003, 11:15 AM
sneezy sneezy is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: London
Posts: 8 sneezy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
this script is live @

http://www.mcexecutive.com/test/contact_form.asp

many thanks

Reply With Quote
  #10  
Old August 8th, 2003, 11:39 AM
sneezy sneezy is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: London
Posts: 8 sneezy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
new error message



Microsoft VBScript compilation error '800a0401'

Expected end of statement

/test/contact_post1.asp, line 5

Dim strName = Trim(Request.Form("name"))

Reply With Quote
  #11  
Old August 8th, 2003, 01:28 PM
Vlince Vlince is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Canada, Quebec, Montreal
Posts: 410 Vlince User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
OH BOY !!!

I can't believe I missed that LOL(at myself) TGIF indeeded...


You're in ASP, NOT in ASP.NET so you **CAN'T** do this:

Dim strMyString = "This is my string"

YOU CAN'T, you must FIRST declare the variable THEN assign someting to it.

God, I can't beliebe I didn't see this before LOL!!!

What *YOU* must do is declare the variables:

<%
Dim objMail
Dim myBody
Dim strName
Dim strMorf
. . .
. .
.

'Then assign the proper values to them...

strName = Trim(Request.Form("name"))
strMorf = Trim(Request.Form("morf"))
. . .
. .
.

%>


Hope this helps!
Sincerely

Vlince

Reply With Quote
  #12  
Old August 11th, 2003, 04:48 AM
sneezy sneezy is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: London
Posts: 8 sneezy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi

ok getting really confused but trying to stay patient! Hope to get this up and working today! Got a deadline so I made the changes and now my code looks like this:

<% @language="VBSCRIPT" %>
<%
Dim objMail
Dim myBody
Dim strName
Dim strSex
Dim lngAge
Dim strPresentsalary
Dim strPositionofinterest
Dim strExpertise
Dim strLocationnow
Dim strLocationwanted
Dim strHomephone
Dim strMobile
Dim strWorkphone
Dim strEmail
Dim strMessage
Dim strInfo
strName = Trim(Request.Form("name"))
strSex = Trim(Request.Form("sex"))
lngAge = Trim(Request.Form("age"))
strPresentsalary = Trim(Request.Form("presentsalary"))
strPositionofinterest = Trim(Request.Form("positionofinterest"))
strExpertise = Trim(Request.Form("expertise"))
strLocationnow = Trim(Request.Form("locationnow"))
strLocationwanted = Trim(Request.Form("locationwanted"))
strHomephone = Trim(Request.Form("homephone"))
strMobile = Trim(Request.Form("mobile"))
strWorkphone = Trim(Request.Form("workphone"))
strEmail = Trim(Request.Form("email"))
strMessage = Trim(Request.Form("message"))
strInfo = Trim(Request.Form("info"))
myBody = strName & "<br>" & _ strMorf & "<br>" & _ lngAge & "<br>" & _ strPresentsalary & "<br>" & _ strPositionofinterest& "<br>" & _ strExpertise & "<br>" & _strLocationnow & "<br>" & _ strLocationwanted & "<br>" & _ strHomephone & "<br>" & _ strMobile & "<br>" & _ strWorkphone & "<br>" & _ strEmail & "<br>" & _ strMessage & "<br>" & _ strInfo & "<br>"
Set objMail = Server.CreateObject ("CDONTS.NewMail")
objMail.From = request.form("email")
objMail.To = "sarah.adams@mehdiward.com"
objMail.Subject = "Customer Contact"
objMail.Body = myBody
objMail.Send

Set objMail = nothing

Response.Redirect("contact_thanks.asp")
%>


Its defiently growing!!

Got this error message after downloading it.


Microsoft VBScript compilation error '800a0408'

Invalid character

/test/contact_post1.asp, line 33

myBody = strName & "<br>" & _ strMorf & "<br>" & _ lngAge & "<br>" & _ strPresentsalary & "<br>" & _ strPositionofinterest& "<br>" & _ strExpertise & "<br>" & _strLocationnow & "<br>" & _ strLocationwanted & "<br>" & _ strHomephone & "<br>" & _ strMobile & "<br>" & _ strWorkphone & "<br>" & _ strEmail & "<br>" & _ strMessage & "<br>" & _ strInfo & "<br>"
------------------------------^

This is also live to on the test site

http://www.mcexecutive.com/test/contact_form.asp

many thanks

Reply With Quote
  #13  
Old August 11th, 2003, 08:25 AM
Vlince Vlince is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Canada, Quebec, Montreal
Posts: 410 Vlince User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
I've included a downloadable file with your code in it.

Now I don't know if it works since I haven't tested it.

The good thing is that there is comments and nice formating which is better then posting the code in here.


Have a look!

Hope this helps!
Sincerely

Vlince
Attached Files
File Type: asp tmp.asp (3.3 KB, 345 views)

Reply With Quote
  #14  
Old October 9th, 2003, 12:38 AM
leobag leobag is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 1 leobag User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 24 sec
Reputation Power: 0
Vlince, you seem to know your stuff... I hope to get some help by bringing up this topic.

I receive the following error:

CDONTS.NewMail.1 error '80020009'

501 ASP Service Disabled


when the mail.from object is an email address like "user@domain.co.uk" or "user@domain.us"

However, I receive no errors when the from object is "user@domain.com" or "user@domain.cc"

Any ideas??

Thanks,
Leo

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Contact Form (Newbie)


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not