Hello,
I have a page, thanks.asp which uses classic ASP VBSCRIPT & CDONTS to send
mail, for example:
<%
Set bc = Server.CreateObject("MSWC.BrowserType")
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Web Site Form Results"
objMessage.Sender = "ad***@domain.co.uk"
objMessage.To = "ga**@domain.co.uk"
objMessage.Bcc = ""
objMessage.Cc = ""
objMessage.HTMLBody ="MESSAGE BODY HERE"
objMessage.Send
%>
Now, imagine what happens if someone comes back to this page via the history
or if they hit refresh, another email is sent (a duplicate).
How easy is it to stop this happening?
One way I am thinking about (not sure if it will work):
----------------------------------------------------------
if Session("sendMail") <> 0 then
Session("sendMail") = 1
Else
Session ("sendMail")= 0
End if
If Session("sendMail")=1 then
Send Mail
Else
Dont Send mail
End if
Session("sendMail=0")
----------------------------------------------------------
This basically says, if there is a session called 0, then dont send mail.
However, if there is a session greater or less than 0, send the mail and
THEN set the session to 0 to stop it happening on refresh.
Is this the best way to do it?
Gary.