Log in

View Full Version : Simple send email issue



sniperman
12-15-2010, 06:35 AM
Hi, having some problems trying to get this code to send an email after it has updated a MS Access database.

The query to MS Access works fine. Being able to use those same variables requested from a HTML form however does not work.


<%
action=trim(request("action"))

if action="add" then

set rs=server.CreateObject("adodb.recordset")
sql="select * from Payment"
rs.open sql,conn,1,3
rs.addnew

rs("Model")=trim(Request("Model"))
rs("Description")=trim(Request("Description"))
rs("Quantity")=trim(Request("Quantity"))
rs("Price")=trim(Request("Price"))
rs("Postage")=trim(Request("Postage"))
rs("Total")=trim(Request("Total"))
rs("CustomerName")=trim(Request("CustomerName"))
rs("Address")=trim(Request("Address"))
rs("Email")=trim(Request("Email"))
rs("OrderDate")=trim(Request("OrderDate"))
rs("Message")=trim(Request("Message"))
rs("adddate")=now()


rs.update
rs.close
set rs=nothing

sFrom = Request.Form("name") & "<" & Request.Form("email") & ">"
sTo = "mail@mail.com"
sSubject = "SUBJECT LINE HERE"

sMessage = "Name : " & Request.Form("name") & vbcrlf & vbcrlf _
& "e-mail : " & Request.Form("email") & vbcrlf & vbcrlf _
& "Their Message:" & Request.Form("Message")

Set objNewMail = CreateObject("CDONTS.NewMail")
objNewMail.Send sFrom, sTo, sSubject, sMessage
Set objNewMail = Nothing

response.Write "<script language=javascript>alert('Your submission was successful!');window.location.href='Payment.html';</script>"

end if

%>

Dee_Veloper
02-02-2011, 09:08 PM
In the database update you are using only "request"

in the email you are using "request.form"

if the data is coming from the querystring use "request.querysting"

if the data is coming from a post then use "request.form"

using only "request" will search both but takes the querystring values if they exist.