This topic is locked

more than one event on add record?

2/2/2012 8:36:12 AM
ASPRunnerPro General questions
author

I need to send the new record data in an email and redirect the user to the view page after the new records is added. This code won't work. Can you help? Thanks.
'** Redirect to another page ****

Response.Redirect "subscription_table_view.asp?editid1="&keys("salesid")

End Sub
'** Send email with new data ****

' do not forget to setup email parameters like From, SMTP server etc

' on 'Security->User login settings' dialog
Dim dkeys, tmpDict, msg, n

msg =""
dkeys = values.keys

For n = 0 To values.Count-1

if not IsBinaryType(GetFieldType(dkeys(n),"")) then

msg = msg & dkeys(n) & " : " & values(dkeys(n)) & vbcrlf

end if

Next
set tmpDict = CreateObject("Scripting.Dictionary")

tmpDict("to")="--rbegin--bob@website.com--rend--"

tmpDict("subject")="SUBSCRIPTION TO NEW MAPS"

tmpDict("body")=msg

set ret=runner_mail(tmpDict)

if not ret("mailed") then

response.write ret("message")

end if
' Place event code here.

' Use "Add Action" button to add code snippets.

Sergey Kornilov admin 2/3/2012

As a first step remove redirect code and End Sub. Then make sure that email address where you send email is correct.

500508 2/3/2012

Okay done (see below).
How can I both send the email and redirect to the view page? Everything works, but my boss wants the email and he wants users to be taken to the view page after they hit the submit button. Thanks.
'** Send email with new data ****

' do not forget to setup email parameters like From, SMTP server etc

' on 'Security->User login settings' dialog
Dim dkeys, tmpDict, msg, n

msg =""
dkeys = values.keys

For n = 0 To values.Count-1

if not IsBinaryType(GetFieldType(dkeys(n),"")) then

msg = msg & dkeys(n) & " : " & values(dkeys(n)) & vbcrlf

end if

Next
set tmpDict = CreateObject("Scripting.Dictionary")

tmpDict("to")="--rbegin--bob@mywebsite.com--rend--"

tmpDict("subject")="--rbegin--Subscription alert--rend--"

tmpDict("body")=msg

set ret=runner_mail(tmpDict)

if not ret("mailed") then

response.write ret("message")

end if
' Place event code here.

' Use "Add Action" button to add code snippets.

Sergey Kornilov admin 2/4/2012

Send email first and then redirect.