This topic is locked
[SOLVED]

 Email Button on View Page

12/20/2011 1:08:05 PM
ASPRunnerPro General questions
G
gdmacdo author

I would like to create a button on a view page. The button should read the HA_Email field that is stored on the form and email certain records. I have done this on a After Record Added event but I am unsuccessful on making a button on the view page.
I have tried this as a very basic email test the view page:Before process
'button name on view page

if GetRequestForm("Email Health Assistant")="1" then

Dim dkeys, tmpDict, msg, rstemp, alink, n

set tmpDict = CreateObject("Scripting.Dictionary")

'hard coded email address to test easy mail

tmpDict("to")="email@aol.com"

tmpDict("subject")="Screening Request for Student#:"
set ret=runner_mail(tmpDict)

if not ret("mailed") then

response.write ret("message")

end if

end if
Button on view page.
<INPUT id=Email_Health_Assistant class=button value=Email&nbsp;Health&nbsp;Assistant type=button typeid="ib">
****
I have also tried a code snippet with client before button and server code:
response.Flush
dim arr,i
currentTable = "HA_Screening_Notice"
if keys.Count>0 then
email_list=""
set rmail=CreateDictionary()
for i=0 to keys.Count-1
arr=split(keys.Item(i)("ID"),"&")
if asp_count(arr)>=0 then
set arr2=CreateDictionary()
arr2("ID")=asp_urldecode(arr(0))
where = KeyWhere(arr2,"")
set data = dal.Table(currentTable).Query(where,"")
if data("HA_Email")<>"" then
email_list=email_list & data("HA_Email") & ","
end if
data.close
set data=nothing
end if
next
if email_list<>"" then
email_list = left(email_list,len(email_list)-1)
end if
' send the email
rmail("to")=email_list
rmail("subject")="Sample subject"
rmail("body")="Your email message here"
set arr = runner_mail(rmail)
result("txt") = "Emails were sent."
' if error happened print a message on the web page
if arr("mailed") then
errmsg = "Error happened:
"
errmsg = errmsg & "File: " & arr("source") & "
"
errmsg = errmsg & "Line: " & arr("number") & "
"
errmsg = errmsg & "Description: " & arr("description") & "
"
result("txt") = errmsg
end if
end if
Any assistance would be appreciated. Also, is there a way to have a javascript prompt/popup to enter the email address?

Sergey Kornilov admin 12/20/2011

I would suggest to save field value in session variable. You can do that using ProcessValues event:

http://xlinesoft.com/asprunnerpro/docs/process_record_values.htm
Then you can use this session variable in your server side code.
How to get user input in Javascript:

http://www.tizag.com/javascriptT/javascriptprompt.php