473,320 Members | 1,870 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Refresh & Session Switch.

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.

Jul 19 '05 #1
1 1739
Gary W wrote:
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.


That should work fine. I'd do something like this though:

If Not Session("sendMail") Then
If objMessage.Send Then Session("sendMail") = True
End If

And don't forget to close out your objects:
Set objMessage = Nothing

--

kindler chase
http://www.ncubed.com
Home of SuperInvoice: The Online Invoicing Application.
Organize your billing process and impress your clients.

news://news.ncubed.com/support
n3 Support Group
Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Mark | last post by:
I have a working PHP/MySQL application used for data entry. The data entry screen includes a "Save" button. The PHP code for this button looks like this: if (isset($_POST)) { if ($_POST ==...
0
by: Michelle Keys | last post by:
I am trying to call a print function to print a string from a database using javascript. Which is RC_DATA of Varchar2(2500). This is a javascript is not being used. I have a thing that needs to...
10
by: tasmisr | last post by:
This is an old problem,, but I never had it so bad like this before,, the events are refiring when clicking the Browser refresh button. In the Submit button in my webform, I capture the server side...
8
by: TS | last post by:
Im in a web page and call an asynchronous method in business class. the call back method is in the web page. When page processes, it runs thru code begins invoking the method then the page...
1
by: ratnakarp | last post by:
Hi, I have a search text box. The user enters the value in the text box and click on enter button. In code behind on button click i'm writing the code to get the values from the database and...
1
by: achoo | last post by:
Is it possible to extend a Web service proxy so that it understands an HTTP refresh page? Explanation: * The Web service proxy was autogenerated by Visual Studio .NET 2003 from the Web...
3
by: Ned Balzer | last post by:
Hi all, I posted this question some time ago in an earlier thread but so far I still don't have an understanding of why this is happening or what I can do to fix it. I use Session variables,...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
7
by: bhavin30 | last post by:
Is there a way to obtain user information (using LOGON_USER server variables) when you have set up the security to Anonymous Access? I have tried setting the security to both Anonymous + Window...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.