I'm really struggling with handling errors in ASP.
I have a script that is sending out emails from a MS SQL database where it gets that email addresses and the actual mail itself.
The script loops through the addresses, sending 50 at a time so as not to block the queue.
The problem is that whenever there is an invalid or illegal email address the sending stops and the page returns a 500 error.
So I added the On Error Resume Next tag and now it seems that instead it sends out duplicate emails.
I'm not sure how to resolve this but it seems it sends sometimes 2 or sometimes 3 emails to each address.
It seems to resend to already sent mails when the page number updates but I'm not entirely sure. But it seems to send the first 50 on page 1 then the first 100 on page 2 then the first 150 on page 3 instead of sending 0-50 on page 1, 51-100 on page 2, 101 - 150 on page 3 etc etc.
Either this, or when there's an error in an email address or it is returned undelivered, the script resends all the emails on the current page?
Naturally I just want one email to each address and not to stop when there's an email with an email address in the database.
I'm not an expert with [login to view URL] and using this so looking for someone who can resolve this for me.
When you see the code I'm sure you'll see where the problem is but I just can't figure it out. (Web designer not programmer).
Would really appreciate some help as I've been going mental now for the past 6 hours trying to place If [login to view URL] at different places in the code without success.
Attached is a copy of the code.