I have two asp pages. One collects data, and second one sends thankyou email. The secong page sends email as many times as users refreshes the page. How can I stop reloading the page. Please help.
This might not be the "best" way but an idea nonetheless...
Wrap the block of code that does the email sending with an if statement similar to:
Code:
if session("emailsent") is nothing or session("emailsent") = "no" then
' your email code
end if
And after you send the mail, set session("emailsent") = "yes"
This might need tweaked to check for other possibilities of session("emailsent") -- I can't remember if you should check for isnull or empty quotes or what. Also, you'll need a point in your code (somewhere else most likely) where you clear out that flag and let another email be sent.
Why don't you make the page that sends the email a separate page, then redirect to the destination page? That would avoid any problems with refreshing.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.