Reputation: 77
I am doing some maintence on an ASP website, and have found that it is sending duplicate emails. I cannot figure out how it is doing this. I have pasted the code here http://pastebin.com/Beb94PiC
On line 443 is the function SendMsg2. As far as I can tell the function is only called once. Any alerts or messages only come up once.
When the emails are sent the objMessage.TO = email1 comes in once, and then does not appear on any of the second emails. I am thinking that whatever is making it run twice is also clearing the variable.
Thanks for your help.
Upvotes: 0
Views: 576
Reputation: 1685
Your function is named "SendMsg2" but in Line 478 you set
SendMsg = objMessage.Send
Perhaps that has some side effects when function SendMsg exists.
Upvotes: 1
Reputation: 17010
Off hand, I don't see anything glaring that I can simply put a finger on to help. The best way to solve ASP issues is one of two avenues:
Personally, VB COM is a lot of overhead for a legacy application. While it allows for better instrumentation, you have to write a lot of code. Unless the application has a much longer shelf life than it should at this time, not your best bet. That leaves #2.
Response.Write entry and exit from each routine. Youc an then see the flow printed out and determine where the mail routine is being called a second time. If that does nothing, then it could be user clicking the button more than once (impatient user). If the latter, you should make a button disable.
One way to tracking things down is add a "session id" to the mix. refactor the mail routine(s) to accept an id value and then you can code "if session ID then don't fire off email" into the mix. The ID gets stored after the first email is sent off and any additional calls will see the id already in the mix. I say session id in quotes, as you both have to work with the concept of session and the concept of initial flow to cover both user error (clicking more than once) and code flow error. If you can send multiple emails in a single session, you need to keep some type of "I sent this email in this session" value in the mix so you don't add the error of not sending emails to the mix.
You should take the time to both correct the flow and correct user error. But take the time to troubleshoot first, so you see if there are any other artifacts. In classic ASP code only, this means writing values to the Response stream (so crude, like hand push lawn mowers?).
Upvotes: 0