|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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 |
|
#3
|
|||
|
|||
|
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 |
|
#4
|
|||
|
|||
|
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 |
|
#5
|
|||
|
|||
|
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? |
|
#6
|
|||
|
|||
|
CDONTS.NewMail.1 error '80020009'
501 ASP Service Disabled /test/contact_post1.asp, line 10 the above error message |
|
#7
|
|||
|
|||
|
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... |
|
#8
|
|||
|
|||
|
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? |
|
#9
|
|||
|
|||
|
|
|
#10
|
|||
|
|||
|
new error message
Microsoft VBScript compilation error '800a0401' Expected end of statement /test/contact_post1.asp, line 5 Dim strName = Trim(Request.Form("name")) |
|
#11
|
|||
|
|||
|
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 |
|
#12
|
|||
|
|||
|
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 |
|
#13
|
|||
|
|||
|
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 |
|
#14
|
|||
|
|||
|
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 |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > Contact Form (Newbie) |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|