This topic is locked

Use a variable in rmail

9/4/2009 12:04:24 PM
ASPRunnerPro General questions
B
bshuttlesw author

Is it possible in the following code to have the "rmail("to")=" code line send the emails to the address or address's based on a emailaddress field from the records selected vs a single hardcoded value? This is in the list page before process, Thank you.
Function BeforeProcessList(conn)
response.Flush

dim arr,i

if Request.Form("a")="email" then

if Request("selection[]").Count>0 then

body=""

set rmail=CreateDictionary()

for i=1 to Request.Form("selection[]").Count

arr=split(Request.Form("selection[]").Item(i),"&")

if asp_count(arr)>=0 then

set keys=CreateDictionary()

keys("ContactID")=asp_urldecode(arr(0))

where = KeyWhere(keys,"")

set data = dal.contact.Query(where,"")

body=body & "Response: " & data("Response") & vbcrlf

body=body & "Comments: " & data("Comments") & vbcrlf

body=body & "Employee: " & data("LastName") & vbcrlf & "-------------------" & vbcrlf & vbcrlf

data.close

set data=nothing

end if

next
' send the email
rmail("to")="email@home.net"

rmail("subject")="Sample subject"

rmail("body")=body
' if error happened print a message on the web page

if arr("mailed") then

response.Write "Error happened:
"

response.Write "File: " & arr("source") & "
"

response.Write "Line: " & arr("number") & "
"

response.Write "Description: " & arr("description") & "
"

end if

end if

end if
End Function ' BeforeProcessList

Sergey Kornilov admin 9/4/2009
B
bshuttlesw author 9/4/2009

I have tried using:
rmail("to")=data("emailaddress")

rmail("subject")=data("subject")

rmail("body")=data("Comments")
goes to a blank screen. I only wish to email those I have selected in the begining of the code.