Forum Moderators: open

Message Too Old, No Replies

form not passing values to email

         

tjones

10:05 pm on Mar 10, 2004 (gmt 0)

10+ Year Member



Hi,

Hoping someone can help -- I've got a form that I'd like to have send the form values to me via an email. I'm using CDOSYS. The email sends fine, however the form values are not getting passed along to the email.. i've looked at lots of forums .. not seeing anyone havinga similar problem, am i making a simple error!? please help! thanks!

<%
SUB sendmail
Dim objCDO
Dim iConf
Dim Flds
Dim Name
Dim Address
Dim Address2
Dim Email
Dim Profession
Dim Speciality
Dim License

Const cdoSendUsingPort = 2

Set objCDO = Server.CreateObject("CDO.Message")
Set iConf = Server.CreateObject("CDO.Configuration")

Set Flds = iConf.Fields
With Flds
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "mail-fwd"
.Item(cdoSMTPServerPort) = 25
.Item(cdoSMTPconnectiontimeout) = 10
.Update
End With

Set objCDO.Configuration = iConf

objCDO.From = "someuser@somedomain.com"
objCDO.To = "someuser@somedomain.com"
objCDO.Subject = "Form Test"
objCDO.HTMLBody = "Name: " & Name & vbCrLf & _
" Address: " & Address & vbCrLf & _
" Address2: " & Address2 & vbCrLf & _
" Email: " & Email & vbCrLf & _
" Profession: " & Profession & vbCrLf & _
" Speciality: " & Speciality & vbCrLf & _
" License #: " & License & vbCrLf & "."

objCDO.Send

END SUB

Name = TRIM( Request.Form( "name" ) )
Address = TRIM( Request.Form( "address") )
Address2 = TRIM( Request.Form( "address2" ) )
Email = TRIM( Request.Form( "email") )
Profession = TRIM( Request.Form( "profession") )
Speciality = TRIM( Request.Form( "speciality") )
License = TRIM( Request.Form( "license") )

If Email <> "" THEN
sendMail

'Cleanup
Set ObjCDO = Nothing
Set iConf = Nothing
Set Flds = Nothing

Response.redirect "cdo.htm"
' Any existing page can be used for the response redirect method
END IF

%>

<HTML>
<HEAD><TITLE>Email Form</TITLE></HEAD>
<FORM METHOD="POST" ACTION="<%=Request.ServerVariables("SCRIPT_NAME")%>">
<BR>Name: <INPUT NAME="name" TYPE="text" SIZE=40>
<BR>Address: <INPUT NAME="address" TYPE="text" SIZE=40>
<BR>Address2: <INPUT NAME="address2" TYPE="text" SIZE=40>
<BR>Email: <INPUT NAME="email" TYPE="text" SIZE=40>
<BR>Profession: <INPUT NAME="profession" TYPE="text" SIZE=40>
<BR>Speciality: <INPUT NAME="speciality" TYPE="text" SIZE=40>
<BR>License #: <INPUT NAME="license" TYPE="text" SIZE=40>

<BR><INPUT TYPE="SUBMIT" VALUE="Send Mail">
</FORM>

Birdman

10:32 pm on Mar 10, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hello, I'm not an ASP guy but it looks like you may be NULLing your variables in the SUB. I would try moving this block of code into the SUB, just after the you initialize the vars(Dim Name etc..).

Name = TRIM( Request.Form( "name" ) )
Address = TRIM( Request.Form( "address") )
Address2 = TRIM( Request.Form( "address2" ) )
Email = TRIM( Request.Form( "email") )
Profession = TRIM( Request.Form( "profession") )
Speciality = TRIM( Request.Form( "speciality") )
License = TRIM( Request.Form( "license") )