Jump to content

ASP mail form


astralaaron

Recommended Posts

I am getting my first glimps of asp, there is much similarity to php like I expected.I have a questionin the php form you can add on to the message variable with .= "value";

$message ="-----FORM INFORMATION----- \r\n";$message.='FIRST NAME: '.$first_name."\r\n";$message.='LAST NAME: '.$last_name."\r\n";$message.='CITY: '.$city."\r\n";$message.='STATE: '.$state."\r\n";$message.='HOME PHONE: '.$hphone."\r\n";$message.='MOBIL PHONE: '.$mphone."\r\n";$message.='PROJECT BUDGET: '.$pbudget."\r\n";$message.='TIME FRAME: '.$timeframe."\r\n";$message.='BEST TIME TO CALL: '.$besttime."\r\n";$message.='PROJECT TYPE: '.$project_type."\r\n";$message.='KEEP IN THE LOOP: '.$loop."\r\n";$message.="----------END OF FORM----------\r\n\r\n";

I am trying to get do the same thing in ASP, here is what I have so far

<%dim xfirstdim xlastdim xcitydim xstatedim xzipdim xhphonedim xmphonedim xpbudgetdim xtimeframedim xbesttimedim xpooltypedim xloopxfirst = request.querystring("first")xlast = request.querystring("last")xcity = request.querystring("city")xstate = request.querystring("state")xzip = request.querystring("zip")xhphone = request.querystring("hphone")xmphone = request.querystring("mphone")xpbudget = request.querystring("pbudget")xtimeframe = request.querystring("timeframe")xbesttime = request.querystring("besttime")xpooltype = request.querystring("pooltype")xloop = request.querystring("loop")dim sendtosendto = "csr@iPoolQuotes.com"'Sends an emaildim mailset mail = Server.CreateObject("CDO.Message")mail.To = Request.Form("To")mail.From = Request.Form("From")mail.Subject = Request.Form("Subject")mail.TextBody = Request.Form("Body")mail.Send()Response.Write("Mail Sent!")'Destroy the mail object!set mail = nothing%>

(i just copy and pasted the mail.object part in there as you could probably guess..) i think I am pretty close to getting this thing working... need a little bit of advice, i just noticed they are catching the variables with request.form ....which i have not seen before, i thought i had to request.querystring() into variables .. some help neededA

Link to comment
Share on other sites

Here is where I am at... it seems like it should work, the variables are "echoing" out onto the page...

<%Dim xfirst, xlast, xcity, xstate, xzip, xhphone, xmphone, xpbudget, xtimeframe, xbesttime, xpooltype, xloopxfirst = request.form("first")xlast = request.form("last")xcity = request.form("city")xstate = request.form("state")xzip = request.form("zip")xhphone = request.form("hphone")xmphone = request.form("mphone")xpbudget = request.form("pbudget")xtimeframe = request.form("timeframe")xbesttime = request.form("besttime")xpooltype = request.form("pooltype")xloop = request.form("loop")if (xloop = 1) thenxloop = "keep me in the loop"else xloop = "Don't keep me the loop"end ifzfirst = "First name: " & xfirst & "<br>"zlast = "Last name:" & xlast & "<br>"zcity = "City: " &xcity & "<br>"zstate = "State: " & xstate & "<br>"zzip = "Zip: " & xzip & "<br>"zhphone = "Home Phone: " & xhphone & "<br>"zmphone = "Mobil Phone: " & xmphone & "<br>"zpbudget = "Project Budget " & xpbudget & "<br>"ztimeframe = "Time Frame: " & xtimeframe & "<br>"zbesttime = "Best Time: " & xbesttime & "<br>"zpooltype = "Pool Type: " & xpooltype & "<br>"zloop = "Keep In Loop?: " & xloop & "<br>"Dim inqr, sendto, fromus, subjectsendto = "aron@localhost"fromus = "www.ipoolquotes.com"subject = "index form message"inqr = zfirst & zlast & zcity & zstate & zzip & zhphone & zmphone & zpbudget & ztimeframe & zbesttime & zpooltype & zloopresponse.write(inqr)Dim mailSet mail = Server.CreateObject("CDO.Message")mail.To = sendtomail.From = fromusmail.Subject = subjectmail.TextBody = inqrmail.Send()Response.Write("Mail Sent!")Set mail = nothing%>

but the mail will not send, I use the argosoft offline mail server to test the php mail functions... they work but this one gives me this error:CDO.Message.1 error '80040220'The "SendUsing" configuration value is invalid./aaroniis/indexmail.asp, line 53 Set mail = Server.CreateObject("CDO.Message")this line is confusing me.. i read that the CDO. is a built in mail object of ASP..but they did not explain Message, is it a variable i am suposed to be using? where did it come from.. whats it mean?

Link to comment
Share on other sites

just found someone posting about the same error and they said this works:<%Set cdoConfig = CreateObject("CDO.Configuration")With cdoConfig.Fields.Item(cdoSendUsingMethod) = cdoSendUsingPort.Item(cdoSMTPServer) = ""<enter_mail.server_here>"".UpdateEnd WithSet cdoMessage = CreateObject("CDO.Message")With cdoMessageSet .Configuration = cdoConfig.From = "from@me.com".To = "aaron@localhost".Subject = "Sample CDO Messag".TextBody = "This is a test for CDO.message".SendEnd WithSet cdoMessage = NothingSet cdoConfig = Nothing%>i dont know what to put as my mail server, I tried localhost and 127.1.0.0 the mail server is running.. argosoft

Link to comment
Share on other sites

If it's installed on your local machine then localhost should work. There are 2 quotes before and after the server name, make sure there is only one quote on either side.Also, if you're just starting out with ASP, do yourself a favor and use Javascript instead of VBscript. You will find fewer examples that use Javascript, but it is much more powerful and easy to use vs. VBscript.

Link to comment
Share on other sites

ASP isn't a language, it's more of a framework. You can write it with other languages. The code you have above is written in VBscript. Here's the same thing in java script:

<%@LANGUAGE = "Javascript" %><%var cdoConfig = Server.CreateObject("CDO.Configuration");cdoConfig.Fields.Item(cdoSendUsingMethod) = cdoSendUsingPort;cdoConfig.Fields.Item(cdoSMTPServer) = "server";cdoConfig.Fields.Update();var cdoMessage = Server.CreateObject("CDO.Message");cdoMessage.Configuration = cdoConfig;cdoMessage.From = "from@me.com";cdoMessage.To = "aaron@localhost";cdoMessage.Subject = "Sample CDO Messag";cdoMessage.TextBody = "This is a test for CDO.message";cdoMessage.Send();%>

If you're not confused yet, try this: you can write an ASP.NET application using PHP as the language.You've got to be kidding mehttp://en.wikipedia.org/wiki/.NET_Languages

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...