npala2001
09-29-2004, 03:24 AM
I am using ASP to grab data from an access database then I am using CDONTS to then send an email using the data that I grabbed with ASP from within the access database. The problem is that I am finding it a little confusing on how to move to the next record within the Query using ASP. Below is the script I am written so far - I am not sure if it is correct. I am a newbie at ASP so can you please speak terminology that I can understand. Thanks guys you have helped me in the past I hope you can help me now.
<% Option Explicit
Dim strSubject
Dim objMsg
Dim strBodies
strSubject = "Subject Line"
strBodies = "The body of the Email"
Set adoCon = Server.CreateObject("ADODB.connection")
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("name of database.mdb")
Set rs = Server.CreateObject("ADODB.Recordset")
strSQL = "Name of Query"
rs.Open strSQL, adoCon
do while not rs.eof
if rs("The Field Within the Query I am Using") = 1 then
rs.movenext
loop
Set objMsg = Server.CreateObject("CDONTS.NewMsg")
objMsg.From = My Email Address
objMsg.To = rs("The Field Within the Query I am Using")
objMsg.CC = strFrom
objMsg.Subject = strSubject
objMsg.BodyFormat = "0"
objMsg.MailFormat = "0"
objMsg.Body = strBodies
objMsg.Importance = "2"
objMsg.Send
end if rs("The Field Within the Query I am Using") =0
Set objMsg = Nothing
rs.Close
Set rs = Nothing
Set adoCon = Nothing
%>
<% Option Explicit
Dim strSubject
Dim objMsg
Dim strBodies
strSubject = "Subject Line"
strBodies = "The body of the Email"
Set adoCon = Server.CreateObject("ADODB.connection")
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("name of database.mdb")
Set rs = Server.CreateObject("ADODB.Recordset")
strSQL = "Name of Query"
rs.Open strSQL, adoCon
do while not rs.eof
if rs("The Field Within the Query I am Using") = 1 then
rs.movenext
loop
Set objMsg = Server.CreateObject("CDONTS.NewMsg")
objMsg.From = My Email Address
objMsg.To = rs("The Field Within the Query I am Using")
objMsg.CC = strFrom
objMsg.Subject = strSubject
objMsg.BodyFormat = "0"
objMsg.MailFormat = "0"
objMsg.Body = strBodies
objMsg.Importance = "2"
objMsg.Send
end if rs("The Field Within the Query I am Using") =0
Set objMsg = Nothing
rs.Close
Set rs = Nothing
Set adoCon = Nothing
%>