This topic is locked

Help - Capture form values and email to selected records

9/18/2011 4:04:15 PM
ASPRunnerPro General questions
L
lnemer author

I have a form with a checkbox that when selected, the completed form is supposte to be emailed (with all the values) to all records in a table that have "Active" in the User_Status field. The form is using RTF so the email must go out in html.
Can anyone help me with this code?


' After record added
' After record added

Function AfterAdd(values,keys,inline)
bit_Send_Email = GetRequestForm("bit_Send_Email")

News_Attachment_Name = GetRequestForm("News_Attachment_Name")

News_Subject = GetRequestForm("News_Subject")

Reply_Email = GetRequestForm("Reply_Email")

Contact_Phone = GetRequestForm("Contact_Phone")

News_Message = GetRequestForm("News_Message")
Dim dict

Set dict = values
'********** Send email with new data ************
If bit_Send_Email = 1 then
dtNews_Date = GetRequestForm("News_Date")

dtNews_Time = GetRequestForm("News_Time")

dtNews_Date = FormatDateTime(dtNews_Date,vbShortDate)

dtNews_Time = FormatDateTime(dtNews_Time,vbLongTime)
strNews_Attachment_Name = News_Attachment_Name

If strNews_Attachment_Name <> "" then 'include Attachment

strAttach_Link = "http://www.mydomain.com/SFHOA/Members/files/";

strTheAttach_Name = News_Attachment_Name

strHOAAttachment = strAttach_Link + News_Attachment_Name
msg = msg & vbcrlf & "<p>Date Sent: " & News_Date & "</p><p>Time Sent: " & News_Time & "</p>"

msg = msg & vbcrlf & "<p>Subject: " & News_Subject & "</p>"

msg = msg & vbcrlf & "<p>Reply Email: " & Reply_Email & "</p>"

msg = msg & vbcrlf & "<p>Contact Phone: "& Contact_Phone & "</p>"
strAttachment_Name = News_Attachment_Name

msg = msg & "<p>Attachment Link: " & strHOAAttachment & "</a>" & "</p>"

msg = msg & vbcrlf & "Message: " & News_Message & "</p>"


set tmpDict = CreateObject("Scripting.Dictionary")

tmpDict("to")="test@test.com"

set ret=runner_mail(tmpDict)

';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Response.Flush

On Error Resume Next
SET conn = Server.CreateObject("ADODB.Connection")

conn.Open "", ""

strSql = "SELECT DISTINCT Primary_Email_Address FROM HOME_OWNERS WHERE ((User_Status)='Active')"

Set rs = Server.CreateObject("ADODB.Recordset")

rs.Open strSql, conn, 3, 3
On Error Resume Next

rs.MoveFirst

Do while not rs.EOF


strEmail = rs("Primary_Email_Address")
On Error Resume Next

If strEmail <> "" then

'*'*'*'*'*'*'*'*'*'*'*'*'*'* SEND EMAIL TO ALL USERS '*'*'*'*'*'*'*'*'*'*'*'*'*'*'*'*

sendmail strEmail, News_Subject, msg'*'*'*'*'*'*'*'*'*'*'*'*'*'*'

End If
strEmail = ""

rs.MoveNext

loop

rs.close

set rs=Nothing

End If 'If dict("bit_Send_Email") = 1 then
'********** Redirect to another page ************

'Response.Redirect "NEWS_RELEASES_list.asp"
End Function ' AfterAdd

arrAvailableEvents("AfterAdd")=true
Admin 9/18/2011

What version of ASPRunnerPro do you use and what doesn't work right now? Any error messages.

L
lnemer author 9/18/2011

I am using ASPRunnerPro 6.1.
The form processes and adds the record but does not send email and throws the error pasted below. The list page will not display and the following error appears: (When I remove the code the list page displays with no problem).
Microsoft VBScript compilation error '800a03ea'
Syntax error
/Members/include/NEWS_RELEASES_events.asp, line 19
Function AfterAdd(values,keys,inline)

^

Admin 9/19/2011

Odie,
post your application to Demo Account and open a ticket at http://support.xlinesoft.com sending your Demo Account URL. 'Demo Account' button can be found on the last screen in the program.