No luck, the email still has no values:
This is a multi-part message in MIME format.
--CS_MAIL_Part_Boundary_10
Content-Type: text/plain
Content-Transfer-Encoding:
Time
Form ID
--CS_MAIL_Part_Boundary_10
Main Topics
Browse All TopicsI am trying to pass 2 automatic values from my form to my post page which sends me the emailed information. The 2 values are a timestamp and an automatic number assigned as the Primary Key. The problem is that the values do not show up in the email. Everything else does.
Form code:
<input type="hidden" name="time_stamp" value="<%= request.form("time_stamp")
<input type="hidden" name="Number_1" value="<%= request.form("Number_1") %>">
Post page code:
Dim time_stampname,time_stamp,
time_stampname = "Time"
time_stamp = Request.Form("time_stamp")
Number_1name = "Form ID"
Number_1 = Request.Form("Number_1")
Dim mailmsg
Set mailmsg = Server.CreateObject("CDONT
mailmsg.To = "myemail"
mailmsg.From = "server"
mailmsg.Subject = "Form Submission"
mailmsg.Body = time_stampname & vbcrlf&_
time_stamp & vbcrlf&_
Number_1name & vbcrlf&_
Number_1
mailmsg.Host = "mail server"
mailmsg.Send
Set mailmsg = Nothing
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Dim time_stampname,time_stamp,
time_stampname = "Time"
time_stamp = Request.Form("time_stamp")
Number_1name = "Form ID"
Number_1 = Request.Form("Number_1")
Dim mailmsg
Set mailmsg = Server.CreateObject("CDONT
mailmsg.To = "myemail"
mailmsg.From = "server"
mailmsg.Subject = "Form Submission"
MyBody = time_stampname & vbcrlf
MyBody = MyBody & time_stamp & vbcrlf
MyBody = MyBody & Number_1name & vbcrlf
MyBody = MyBody & Number_1
mailmsg.Body= MyBody
mailmsg.Host = "mail server"
mailmsg.Send
Set mailmsg = Nothing
Actually, I think that the problem is here:
<input type="hidden" name="time_stamp" value="<%= request.form("time_stamp")
<input type="hidden" name="Number_1" value="<%= request.form("Number_1") %>">
My guess is that you have no values being passed for time_stamp or for Number_1....
How is the form grabbing these values?
to prove my point, try this at the top of the mail page:
<%
for each objField in Request.Form
response.write(objField & ": " & request.Form(objField) & "<br>")
next
%>
If you have no values in the request objects, they will show up empty in the mail!
FtB
<input type="hidden" name="time_stamp" value="<%= request.form("time_stamp")
<input type="hidden" name="Number_1" value="<%= request.form("Number_1") %>">
should be:
<input type="hidden" name="time_stamp" value="<%= objRS("time_stamp") %>">
<input type="hidden" name="Number_1" value="<%= objRS("Number_1") %>">
just replace objRS with the name of the recordset that is supposed to populate the form.
Fritz the Blank
I must be misunderstanding something. I did the following:
<input type="hidden" name="time_stamp" value="<%= time_stamp("time_stamp") %>">
<input type="hidden" name="Number_1" value="<%= Number_1("Number_1") %>">
and received the following error:
Error Type:
Sun ONE ASP VBScript runtime (0x800A000D)
Type mismatch
/service.asp, line 82
I'm doing this in the form page...is that correct and not in the posting page.
When you are pulling them from a database during the query you should do something like:
Set rs = conn.execute(sql)
then you would put:
<input type="hidden" name="time_stamp" value="<%= rs.fields("time_stamp") %>">
<input type="hidden" name="Number_1" value="<%= rs.fields("Number_1") %>">
Whatever you call your record set is what RS is.
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
DIM objConn
Set objConn = Server.CreateObject("ADODB
objConn.ConnectionString = "DSN=mydb"
objConn.Open
mySQL = "SELECT DISTINCT state_id FROM state ORDER BY state_id"
DIM objRS
Set objRS = Server.CreateObject("ADODB
objRS.Open mySQL, objConn
%>
<html>
<head>
<title>mytitle</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="black"><font color="white">
<form method=Post action=getcus.asp>
<b><font face="Times New Roman,Georgia,Times">*My text!</font></b><br>
<br>
Name<br>
<input type="text" name="t1" size="20"><br>
Title<br>
<input type="text" name="t2" size="20"><br>
Company<br>
<input type="text" name="t3" size="20"><br>
City<br>
<input type="text" name="t4" size="20"><br>
State<br>
<select name="state_name">
<%Do While Not objRS.EOF%>
<option value='<%=objRS("state_id"
Loop
objRS.close
Set objRS = NOTHING
objConn.Close
Set objConn = Nothing
%>
</select><br>
Country<br>
USA<input type="checkbox" name="Country" value="USA"> OTHER<input type="checkbox" name="Country" value="OTHER"> <input type="text" name="t5" size="20"><br>
Email<br>
<input type="text" name="t6" size="20"><br>
<br>
Describe <br>
<textarea rows="4" name="st" cols="50"></textarea><br>
<br>
What do you want ?<br>
select1<input type="checkbox" name="site" value="select1"><br>
select2<input type="checkbox" name="site" value="select2"><br>
select3<input type="checkbox" name="site" value="select3"><br>
<br>
What Services?<br>
select1<input type="checkbox" name="service" value="select1"><br>
select2<input type="checkbox" name="service" value="select2"><br>
select3<input type="checkbox" name="service" value="select3"><br>
select4<input type="checkbox" name="service" value="select4"><br>
<br>
Current location <input type="text" name="t7" size="20"><br>
&n
<br>
Question<br>
<textarea rows="4" name="t8" cols="50"></textarea><br>
<br>
<br>
Question2.<br>
<textarea rows="4" name="t9" cols="50"></textarea><br>
<br>
<br>
Context?<br>
Yes<input type="checkbox" name="context" value="Yes"><br>
No<input type="checkbox" name="context" value="No"><br>
<br>
budget?<br>
<input type="text" name="t10" size="20"><br>
<br>
Questions, Comments?<br>
<textarea rows="4" name="t11" cols="50"></textarea><br>
<br>
<input type="hidden" name="time_stamp" value="<%= objRS("time_stamp") %>">
<input type="hidden" name="Number_1" value="<%= objRS("Number_1") %>">
&n
</form>
</body>
</html>
Okay, so there is nothing populating these:
<input type="hidden" name="time_stamp" value="<%= objRS("time_stamp") %>">
<input type="hidden" name="Number_1" value="<%= objRS("Number_1") %>">
If you want a time stamp, then change the first line to this:
<input type="hidden" name="time_stamp" value="<%= Now()%>">
Please tell me a little more about the value that should be in the Number_1 field.
FtB
Then on the mail page, try this:
'perform your update using a recordset object so that you can get the auto increment ID
Dim time_stampname,time_stamp,
time_stampname = "Time"
time_stamp = Request.Form("time_stamp")
Number_1name = "Form ID"
Number_1 = objRS("Number_1")
Dim mailmsg
Set mailmsg = Server.CreateObject("CDONT
mailmsg.To = "myemail"
mailmsg.From = "server"
mailmsg.Subject = "Form Submission"
mailmsg.Body = time_stampname & vbcrlf&_
time_stamp & vbcrlf&_
Number_1name & vbcrlf&_
Number_1
mailmsg.Host = "mail server"
mailmsg.Send
Set mailmsg = Nothing
You can perform another query after you have inputted it. I think FTB that he wants to mail the Number_1 to himself as evidenced by:
Number_1name & vbcrlf&_
Number_1
So I would do this:
'perform your update using a recordset object so that you can get the auto increment ID
' Open a query to pull the number_1 and Time_stamp from the database. Make it objRS
Dim time_stampname,time_stamp,
time_stampname = "Time"
time_stamp = objRS("time_stamp")
Number_1name = "Form ID"
Number_1 = objRS("Number_1")
Dim mailmsg
Set mailmsg = Server.CreateObject("CDONT
mailmsg.To = "myemail"
mailmsg.From = "server"
mailmsg.Subject = "Form Submission"
mailmsg.Body = time_stampname & vbcrlf&_
time_stamp & vbcrlf&_
Number_1name & vbcrlf&_
Number_1
mailmsg.Host = "mail server"
mailmsg.Send
Set mailmsg = Nothing
When I wrote this:
'perform your update using a recordset object so that you can get the auto increment ID
in my post above, I had in mind something like:
strSQL = "SELECT * FROM tblYourTable WHERE 1=0"
objRS.Open strSQL, objConn,3,3
objRS.AddNew()
objRS("time_stamp") = Request.Form("time_stamp")
objRS("state_ID") = Request.Form("state_name")
objRS.Update()
Number_1 = objRS("Number_1")
In addition instead of on the previous page having:
<input type="hidden" name="time_stamp" value="<%= Now()%>">
He may have the Time_stamp as a datetime field in his database that he writes when he enters the data. I would do that so that I can see when they committed it to the table.
That way he can write the time_stamp from the database.
I am also getting errors when I input the query in the mail page..... see mail page code below in working state. Please let me know where I should input the query:
Response.Buffer = true
dim objConn,objrst
set objConn = Server.CreateObject("ADODB
set objrst = Server.CreateObject("ADODB
objConn.ConnectionString = "DSN=mydb"
objConn.Open
sqltext = "SELECT * FROM service"
objrst.Open sqltext,objConn,3,3
objrst.AddNew
objrst("t1") = Request.Form("t1")
objrst("t2") = Request.Form("t2")
objrst("t3") = Request.Form("t3")
objrst("t4") = Request.Form("t4")
objrst("state_name") = Request.Form("state_name")
objrst("country") = Request.Form("country")
objrst("t5") = Request.Form("t5")
objrst("t6") = Request.Form("t6")
objrst("st") = Request.Form("st")
objrst("site") = Request.Form("site")
objrst("stuff1") = Request.Form("stuff1")
objrst("t7") = Request.Form("t7")
objrst("t8") = Request.Form("t8")
objrst("t9") = Request.Form("t9")
objrst("stuff2") = Request.Form("stuff2")
objrst("t10") = Request.Form("t10")
objrst("t11") = Request.Form("t11")
objrst.update
objrst.Close
Set objrst= Nothing
objConn.close
Set objConn= Nothing
%>
<%Dim t1name,t1,t2name,t2,t3name
t1name = "Name"
t1 = Request.Form("t1")
t2name = "Title"
t2 = Request.Form("t2")
t3name = "Company"
t3 = Request.Form("t3")
t4name = "City"
t4 = Request.Form("t4")
Dim state_namename,state_name,
state_namename = "State"
state_name = Request.Form("state_name")
Countryname = "Country"
Country = Request.Form("Country")
Dim t5name,t5,t6name,t6
t5name = "Other Country"
t5 = Request.Form("t5")
t6name = "Email"
t6 = Request.Form("t6")
Dim stname,st
stname = "Statement:"
st = Request.Form("st")
Dim sitename,site
sitename = "Question?"
site = Request.Form("site")
Dim servicename,service
servicename = "Question?"
service = Request.Form("service")
Dim t7name,t7,t8name,t8,t9name
t7name = "Statement"
t7 = Request.Form("t7")
t8name = "Question?"
t8 = Request.Form("t8")
t9 = "Statement"
t9 = Request.Form("t9")
Dim contextname,context
contextname = "Question?"
context = Request.Form("context")
Dim t10name,t10,t11name,t11
t10name = "Question?"
t10 = Request.Form("t10")
t11name = "Question?"
t11 = Request.Form("t11")
Dim time_stampname,time_stamp,
time_stampname = "Time"
time_stamp = Request.Form("time_stamp")
Dim mailmsg
Set mailmsg = Server.CreateObject("CDONT
mailmsg.To = "me@mydomain"
mailmsg.From = "service@mydomain.com"
mailmsg.Subject = "Form Submission"
mailmsg.Body = t1name & vbcrlf&_
t1 & vbcrlf&_
t2name & vbcrlf&_
t2 & vbcrlf&_
t3name & vbcrlf&_
t3 & vbcrlf&_
t4name & vbcrlf&_
t4 & vbcrlf&_
state_namename & vbcrlf&_
state_name & vbcrlf&_
Countryname & vbcrlf&_
Country & vbcrlf&_
t5name & vbcrlf&_
t5 & vbcrlf&_
t6name & vbcrlf&_
t6 & vbcrlf&_
stname & vbcrlf&_
st & vbcrlf&_
sitename & vbcrlf&_
site & vbcrlf&_
servicename & vbcrlf&_
service & vbcrlf&_
t7name & vbcrlf&_
t7 & vbcrlf&_
t8name & vbcrlf&_
t8 & vbcrlf&_
t9name & vbcrlf&_
t9 & vbcrlf&_
contextname & vbcrlf&_
context & vbcrlf&_
t10name & vbcrlf&_
t10 & vbcrlf&_
t11name & vbcrlf&_
t11 & vbcrlf&_
time_stampname & vbcrlf&_
time_stamp & vbcrlf&_
Number_1name & vbcrlf&_
Number_1
mailmsg.Host = "mail.mydomain.com"
mailmsg.Send
Set mailmsg = Nothing
%></font></b></font></p>
On the form page you have closed ObjConn and ObjRS and set them to nothing much earlier on the page. So once you get to the line where you input the time stamp into the form, it has nothing to enter. I also see on the form page that the query where you set objRS it looks like the query never pulls a time_stamp into the objRS anyway. FtB earlier said that you can change that line on the form to read this:
<input type="hidden" name="time_stamp" value="<%= Now()%>">
That will set the value to the time that the form is displayed to the user to be filled out.
Conversly, you can omit it from the form alltogether and put it on the processing page by changing this " time_stamp = Request.Form("time_stamp")
On the service page I would do this:
<%Response.Buffer = true
dim objConn,objrst
set objConn = Server.CreateObject("ADODB
set objrst = Server.CreateObject("ADODB
objConn.ConnectionString = "DSN=mydb"
objConn.Open
sqltext = "Insert into service (t1, t2, t3, t4, state_name, country, t5, t6, st, site, stuff1, t7, t8, t9, stuff2, t10, t11) values ('"&Request.Form("t1")&"',
objConn.execute(sqltext)
objConn.close
Set objConn= Nothing
%>
PK
OK, so I have the time_stamp working, thanks! I am still a bit confused on how to get the auto increment number. I tried inputting Number_1 = objRS("Number_1")
into the service page but I get an error: Error Type:
Sun ONE ASP VBScript runtime (0x800A000D)
Type mismatch
/getcus.asp, line 125
I don't quite understand the query that FTB wrote up top:
strSQL = "SELECT * FROM tblYourTable WHERE 1=0"
objRS.Open strSQL, objConn,3,3
objRS.AddNew()
objRS("time_stamp") = Request.Form("time_stamp")
objRS("state_ID") = Request.Form("state_name")
objRS.Update()
Number_1 = objRS("Number_1")
Is this query supposed to go in the form page or the service page?
I am going to assume that your database is setting the number_1 auto increment value automatically. What I would do is just after the service page has input the data into the database, I would then query the database based on the same form values for what the Number_1 is.
Just after the input query, I would runa a query on some specific data from the form. You do not specify what t1, t2 t3 or t4 are above. Assuming they are like a name or unique id, you could query on them.
This is an example:
<%
dim objConn,objrst
set objConn = Server.CreateObject("ADODB
set objrst = Server.CreateObject("ADODB
objConn.ConnectionString = "DSN=mydb"
objConn.Open
sqltext = "Select top 1 * from service where t1 = '"&request.form("t1")&"' and t2 = '"&request.form("t2")&"' and t3 = '"&request.form("t3")&"' order by id desc"
set objRS = objConn.execute(sqltext)
If not objRS.eof then
while not objRS.eof
number_1 = objRS("number_1")
wend
end if
objConn.close
Set objConn= Nothing
set objRS = Nothing
%>
What you are doing here is returning the last record inputed that match teh current t1, t2 and t3 values and setting number_1 to the value for number_1 in teh database.
PK
Business Accounts
Answer for Membership
by: pkaledaPosted on 2004-07-11 at 13:56:03ID: 11524912
You can try this:
mailmsg.Body = time_stampname & vbcrlf
mailmsg.Body = mailmsg.Body & time_stamp & vbcrlf
mailmsg.Body = mailmsg.Body & Number_1name & vbcrlf
mailmsg.Body = mailmsg.Body & Number_1