Click to See Complete Forum and Search --> : ASP Code help.


BestOnline
06-19-2006, 01:41 PM
I am new to the ASP scene.

I am trying to email a filled out form to myself, in one of the selections it has a check box selection with 6 selections. I am confused on how I attach the strings together with the Char(36) character. Here is what I am trying to do.

MailBody = MailBody & cStr(If request.form("ne_PrimList")= & Chr(34) & "on" & Chr(34) & then
response.write & Chr(34) & "<br>I am just gathering information" & Chr(34) &
end if
If request.form("ne_PrimList1")= & Chr(34) & "on" & Chr(34) & then
response.write & Chr(34) & "<br>I already have a self directed IRA custodian but need checkbook control through a Self Directed IRA, LLC?" & Chr(34) &
end if
If request.form("ne_PrimList2")= & Chr(34) & "on" & Chr(34) & then
response.write & Chr(34) & "<br>I have an investment in mind or transaction pending" & Chr(34) &
end if
If request.form("ne_PrimList3")= & Chr(34) & "on" & Chr(34) & then
response.write & Chr(34) & "<br>I am interested in finding real estate to purchase with my self directed IRA" & Chr(34) &
end if
If request.form("ne_PrimList4")= & Chr(34) & "on" & Chr(34) & then
response.write & Chr(34) & "<br>I am interested in purchasing an E-Business/Conventional Business/Franchise with my IRA" & Chr(34) &
end if
If request.form("ne_PrimList5")= & Chr(34) & "on" & Chr(34) & then
response.write & Chr(34) & "<br>I want to purchase a property I can live in - Dream Home, Vacation Condo" & Chr(34) &
end if)

If yall need the rest of the code let me know, this is just one part of the code inside the <% %> tags.

God Bless.
-Robert

BestOnline
06-19-2006, 03:06 PM
Well, Ive been doing some searching. I havnt found the problem to that... but I made another one using what I found from the tutorials.

but when I go to test it, I get a HTTP 500 error... here is my code. let me know if there is something wrong.

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
Dim strEmail, strFirstName, strLastName, strAddress, strState, strZip, strPhone, optHearList, strHearOther, optCurrent, strComments, mail, reply, objMail,strPrimList0, strRadioGet, strMoney, strInterest, strNewsletter, strProgram
strEmail = request.form("ne_Email")
strFirstName = request.form("ne_FirstName")
strLastName = request.form("ne_LastName")
strAddress = request.form("ne_Address")
strState = request.form("ne_State")
strZip = request.form("ne_Zip")
optHearList = request.form("ne_HearList").Item
strPhone = request.form("ne_Phone")
strHearOther = request.form("ne_Other")
'-- optCurrent = request.form("new_CurrentList") --
strRadioGet = Request.Form( "ne_CurrentList" )
strPrimList0 = if InStr(Request.Form("ne_PrimList"),"1") > 0) then response.write("I am just gathering information<BR>")
if InStr(Request.Form("ne_PrimList"),"2") > 0) then response.write("I already have a self directed IRA custodian but need checkbook control through a Self Directed IRA, LLC?<BR>")
if InStr(Request.Form("ne_PrimList"),"3") > 0) then response.write("I have an investment in mind or transaction pending<BR>")
if InStr(Request.Form("ne_PrimList"),"4") > 0) then response.write("I am interested in finding real estate to purchase with my self directed IRA<BR>")
if InStr(Request.Form("ne_PrimList"),"5") > 0) then response.write("I am interested in purchasing an E-Business/Conventional Business/Franchise with my IRA<BR>")
if InStr(Request.Form("ne_PrimList"),"6") > 0) then response.write("I want to purchase a property I can live in - Dream Home, Vacation Condo<BR>")
strComments = Request.Form("ne_Comments")
strMoney = Request.Form("ne_Money").Item
strInterest = Request.Form("ne_interest").Item
strNewsletter = Request.Form("new_Newsletter")
strProgram = Request.Form("new_Program")
strComments = Request.Form("new_Comments")

mail = "robert@bestonlineresults.com"
reply = request.form("Email")
Set objMail = Server.CreateObject("CDO.NewMail")
objMail.From = reply
objMail.Subject = "Testing."
objMail.BodyFormat=0
objMail.MailFormat=0
objMail.To = mail
objMail.TextBody = "FirstName: " & strFirstName & vbCrLf & _
"LastName: " & strLastName & vbCrLf & _
"Email: " & strEmail & vbCrLf & _
"Address: " & strAddress & vbCrLf & _
"State: " & strState & vbCrLf & _
"Zip Code: " & strZip & vbCrLf & _
"Phone: " & strPhone & vbCrLf & _
"How did you hear about us: " & strHearList & vbCrLf & _
"Other: " & strHearOther & vbCrLf & _
"Current Objective: " & strRadioGet & vbCrLf & _
"Primary Reasons 1: " & strPrimeList0 & vbCrLf & _
"Primary Reasons 2: " & strPrimeList1 & vbCrLf & _
"Primary Reasons 3: " & strPrimeList2 & vbCrLf & _
"Primary Reasons 4: " & strPrimeList3 & vbCrLf & _
"Primary Reasons 5: " & strPrimeList4 & vbCrLf & _
"Primary Reasons 6: " & strPrimeList5 & vbCrLf & _
"Money: " & strMoney & vbCrLf & _
"Intrests: " & strIntrests & vbCrLf & _
"Want Newsletter?: " & strNewsletter & vbCrLf & _
"More information on Affilate Program?: " & strProgram & vbCrLf & _
"Comments: " & vbCrLf & strComments
objMail.Send
Set objMail = nothing
%>

lmf232s
06-19-2006, 05:29 PM
BestOnline,
Do 2 things for us

Add this line as the very first line of code on your page if you dont already.

<%Option Explicit%>

This line of code will force you to declare all your variables which i see you have already done.

Then in your browser:
Tools/Internet Options/Advanced/

About the 20th check box down
Uncheck - Show friendly HTTP error messages

This will turn your http 500 error message into a usable error message.
Post back the line number and the code that appears on that line number.

BestOnline
06-19-2006, 10:46 PM
Ok, Thanks Ill do this when I get back in the office tommrow.

BestOnline
06-20-2006, 09:46 AM
Ok, I added the line.

But now I get a sytax error when I took off friendly http.

Here is the error

Microsoft VBScript compilation error '800a03ea' Syntax error

/test.asp, line 16

strPrimList = If InStr(Request.Form("ne_PrimList"), "1") > 0) then response.write("I am just gathering information<BR>") if InStr(Request.Form("ne_PrimList"), "2") > 0) then response.write("I already have a self directed IRA custodian but need checkbook control through a Self Directed IRA, LLC?<BR>") if InStr(Request.Form("ne_PrimList"),"3") > 0) then response.write("I have an investment in mind or transaction pending<BR>") if InStr(Request.Form("ne_PrimList"),"4") > 0) then response.write("I am interested in finding real estate to purchase with my self directed IRA<BR>") if InStr(Request.Form("ne_PrimList"),"5") > 0) then response.write("I am interested in purchasing an E-Business/Conventional Business/Franchise with my IRA<BR>") if InStr(Request.Form("ne_PrimList"),"6") > 0) then response.write("I want to purchase a property I can live in - Dream Home, Vacation Condo<BR>")
---------------^


Here is my code its all one line.

strPrimList = if InStr(Request.Form("ne_PrimList"), "1") > 0) then response.write("I am just gathering information<BR>") if InStr(Request.Form("ne_PrimList"), "2") > 0) then response.write("I already have a self directed IRA custodian but need checkbook control through a Self Directed IRA, LLC?<BR>") if InStr(Request.Form("ne_PrimList"),"3") > 0) then response.write("I have an investment in mind or transaction pending<BR>") if InStr(Request.Form("ne_PrimList"),"4") > 0) then response.write("I am interested in finding real estate to purchase with my self directed IRA<BR>") if InStr(Request.Form("ne_PrimList"),"5") > 0) then response.write("I am interested in purchasing an E-Business/Conventional Business/Franchise with my IRA<BR>") if InStr(Request.Form("ne_PrimList"),"6") > 0) then response.write("I want to purchase a property I can live in - Dream Home, Vacation Condo<BR>")

Terrorke
06-21-2006, 02:04 AM
I dont think you can assign a value to a variable like this :

strPrimList = if ...

Try something like this :
if ... then
strPrimList = ...
else
strPrimList = ...
end if

This should work.

BestOnline
06-21-2006, 10:01 AM
Ok, Thanks I believe that worked, but now I get a error on my output into the mail body code. Says that strPrimeList is not defined.

Here is what I did.

if InStr(Request.Form("ne_PrimList"), "1") > (0) Then strPrimList = Response.Write("I am just gathering information<BR>")
if InStr(Request.Form("ne_PrimList"), "2") > (0) Then strPrimList = Response.Write("I already have a self directed IRA custodian but need checkbook control through a Self Directed IRA, LLC?<BR>")
if InStr(Request.Form("ne_PrimList"),"3") > (0) Then strPrimList = Response.Write("I have an investment in mind or transaction pending<BR>")
if InStr(Request.Form("ne_PrimList"),"4") > (0) Then strPrimList = Response.Write("I am interested in finding real estate to purchase with my self directed IRA<BR>")
if InStr(Request.Form("ne_PrimList"),"5") > (0) Then strPrimList = Response.Write("I am interested in purchasing an E-Business/Conventional Business/Franchise with my IRA<BR>")
if InStr(Request.Form("ne_PrimList"),"6") > (0) Then strPrimList = Response.Write("I want to purchase a property I can live in - Dream Home, Vacation Condo<BR>")

And I get a error on this line.

objMail.TextBody = "FirstName: " & strFirstName & vbCrLf & _
"LastName: " & strLastName & vbCrLf & _
"Email: " & strEmail & vbCrLf & _
"Address: " & strAddress & vbCrLf & _
"State: " & strState & vbCrLf & _
"Zip Code: " & strZip & vbCrLf & _
"Phone: " & strPhone & vbCrLf & _
"How did you hear about us: " & optHearList & vbCrLf & _
"Other: " & strHearOther & vbCrLf & _
"Current Objective: " & strRadioGet & vbCrLf & _
"Primary Reasons 1: " & strPrimeList & vbCrLf & _
"Money: " & strMoney & vbCrLf & _
"Intrests: " & strIntrests & vbCrLf & _
"Want Newsletter?: " & strNewsletter & vbCrLf & _
"More information on Affilate Program?: " & strProgram & vbCrLf & _
"Comments: " & vbCrLf & strComments

Thanks again for your help.

lmf232s
06-21-2006, 10:07 AM
because you are using Option explicit you have to define all your variables.

You need to add strPrimeList to you list of declared variables.

Dim strPrimeList

BestOnline
06-21-2006, 10:10 AM
Do I have to make it its own Dim?

Cause here are all my variables.
Dim strEmail, strFirstName, strLastName, strAddress, strState, strZip, strPhone, optHearList, strHearOther, optCurrent, strComments, mail, reply, objMail, strPrimList, strRadioGet, strMoney, strInterest, strNewsletter, strProgram

Thanks for helping.

BestOnline
06-21-2006, 10:14 AM
Ok thank yall so much. I got it to complete, but I have one more problem.

It doesnt send the email to me. Here is what I coded.

mail = "robert@bestonlineresults.com"
reply = request.form("Email")
Set objMail = Server.CreateObject("CDONTS.NewMail")
objMail.From = reply
objMail.Subject = "Testing."
objMail.BodyFormat=0
objMail.MailFormat=0
objMail.To = mail
objMail.Body = "FirstName: " & strFirstName & vbCrLf & _
"LastName: " & strLastName & vbCrLf & _
"Email: " & strEmail & vbCrLf & _
"Address: " & strAddress & vbCrLf & _
"State: " & strState & vbCrLf & _
"Zip Code: " & strZip & vbCrLf & _
"Phone: " & strPhone & vbCrLf & _
"How did you hear about us: " & optHearList & vbCrLf & _
"Other: " & strHearOther & vbCrLf & _
"Current Objective: " & strRadioGet & vbCrLf & _
"Primary Reasons 1: " & strPrimList & vbCrLf & _
"Money: " & strMoney & vbCrLf & _
"Intrests: " & strInterest & vbCrLf & _
"Want Newsletter?: " & strNewsletter & vbCrLf & _
"More information on Affilate Program?: " & strProgram & vbCrLf & _
"Comments: " & vbCrLf & strComments
objMail.Send
Set objMail = nothing

if ("thankyou.html"<>"") then
Response.Redirect("thankyou.html")

end if

lmf232s
06-21-2006, 10:21 AM
at first glance the code looks fine.

Where is your site hosted? On your server or is someone else hosting it?

BestOnline
06-21-2006, 10:25 AM
On a clients server. I am testing it.

Here is the website, I dont have any links to it.

www.houstonrealestateira.com/contactus.asp

After you fill out the information its supposed to send it to me, but I dont get a email even though it redirects to the thankyou.html page.

lmf232s
06-21-2006, 10:34 AM
BestOnline,
This could be a problem w/ a couple of things.

1. your client might not have SMTP running on the web server. Shoot they might not even have it installed. I would check w/ that one first. Make sure that SMTP is running on the web server.

BestOnline
06-21-2006, 10:36 AM
It has that installed. I have another .asp contact form on there that works. So there is something up with the code I hope... Lol.

lmf232s
06-21-2006, 10:58 AM
BestOnline,
The code works fine for me so im going to rule that 1 out.

Use your email address as on the FROM line and see if that works.

BestOnline
06-21-2006, 11:39 AM
Thanks alot. That was the problem. I dont want it to go to the person that filled it out. I want it to go to me for the information.

Really thanks, It helps.
God Bless.
robert@bestonlineresults.com