473,785 Members | 2,310 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Refresh & Session Switch.

Hello,

I have a page, thanks.asp which uses classic ASP VBSCRIPT & CDONTS to send
mail, for example:
<%
Set bc = Server.CreateOb ject("MSWC.Brow serType")
Set objMessage = CreateObject("C DO.Message")
objMessage.Subj ect = "Web Site Form Results"
objMessage.Send er = "ad***@domain.c o.uk"
objMessage.To = "ga**@domain.co .uk"
objMessage.Bcc = ""
objMessage.Cc = ""
objMessage.HTML Body ="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("sendMa il") <> 0 then
Session("sendMa il") = 1
Else
Session ("sendMail") = 0
End if

If Session("sendMa il")=1 then
Send Mail
Else
Dont Send mail
End if

Session("sendMa il=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 1780
Gary W wrote:
Hello,

I have a page, thanks.asp which uses classic ASP VBSCRIPT & CDONTS to
send mail, for example:
<%
Set bc = Server.CreateOb ject("MSWC.Brow serType")
Set objMessage = CreateObject("C DO.Message")
objMessage.Subj ect = "Web Site Form Results"
objMessage.Send er = "ad***@domain.c o.uk"
objMessage.To = "ga**@domain.co .uk"
objMessage.Bcc = ""
objMessage.Cc = ""
objMessage.HTML Body ="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("sendMa il") <> 0 then
Session("sendMa il") = 1
Else
Session ("sendMail") = 0
End if

If Session("sendMa il")=1 then
Send Mail
Else
Dont Send mail
End if

Session("sendMa il=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("sendMa il") Then
If objMessage.Send Then Session("sendMa il") = 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
4924
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 == "") { include ("InsertRecord.inc"); // Insert new record }
0
6438
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 be modified: if(e.CommandName =="Print") { string parsedreceipt = null; parsedreceipt = DecodeReceipt (e.Item.Cells.Text); Session = parsedreceipt;
10
9251
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 click event and I update session information to track the visibilty of some panels in a wizard type navigation ("Next >>" and "<< Back" buttons).. but the refresh button makes another event firing and takes the whole thing to a Choes.. ...
8
5881
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 unloads. When the callback method is raised, only the method in the web page is run and the page never refreshes, it seems it all happens on the server side. I am trying to refresh the constrols on the page inside the callback method, but when id...
1
6428
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 binding it to a repeater control. This repeater control has multiple text boxes and buttons. Can you please tell me how can i do paging in this case ? I'm posting my code below. The problem is that if i click on "AdjustThisAd" button, it opens...
1
2266
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 service's WSDL. It inherits from System.Web.Services.Protocols.SoapHttpClientProtocol. * The Web service is hiding behind a load-balancing content switch
3
3808
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, such as Session("username") to store a lot of information about who is logged in to my app and what they can do. Since the app permits certain users to impersonate other users (permits some users to delegate their work to assistants, who are...
0
5576
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 ******************************************************** For this teeny job, please refer to: http://feeds.reddit.com/feed/8fu/?o=25
7
5358
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 Integrated, without any luck. I'm using IIS 6.0 on Windows Server 2003 Thanks in advance!
0
9647
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9485
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10098
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9958
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7506
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5523
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4058
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2890
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.