Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending Many Email messages

Status
Not open for further replies.

dnavarrojr

Technical User
Aug 2, 2002
3
0
0
US
I have nearly completed a new project for a client and there is one important step that I'm not sure how I'm going to handle it.

I need to send out between 100 and 300 email notifications when a new item is added to the system. However, I can't do it the easy way of just putting all the addresses in a BCC and sending a single message to the SMTP server. Each message must be customized with details only relevant to the individual recipient.

That means, I have to send out all the emails, one at a time, from a .ASP page. My problem is that the ISP we're using for this project has a 180-second (three minute) timeout of all scripts. So I can only send out about 75 to 100 emails before the script times out.

I'm guessing that I just need to send out the emails in batches of 50 and then just refresh the page...? Does that sound like the best way to approach it?

--Dave
 
That would work. Depending on how your storing the emails (ie db) you could probably do a pseudo-paging technique. Say for instance these emails are in a databaase table and have a unique id. What you could do is set up a refresh (using either Meta tags or javascript) and in the address you want it to refresh to place the last processed id in the querystring. Then for your SQL ststement you can do something like:
Code:
If Request.QueryString(&quot;lastProcId&quot;) <> &quot;&quot; Then
   strSQL = &quot;SELECT Top 50 * FROM MyTable WHERE emailId > &quot; & Request.QueryString(&quot;lastProcId&quot;) & &quot; ORDER BY emailId&quot;   'assuming numeric id
Else
   strSQL = &quot;SELECT TOP 50 * FROM MyTable ORDER BY emailId&quot;
End If
This way the first time it loads it would mail the first 50 people in them table. Then place the last person in the querystring for the refresh and on the next load it will get ppl 51-100, etc.

To enhance this a little you could do a check that there are 50 records in the recordset, if there aren't then you have processed the last of the entries in the table so don't write the refresh, otherwise write the refresh with the last id processed.

To keep this speedy I would open your recordset as adOpenForwardOnly. The way you can keep track of the last id processed is by having a temporary variable that you set the id to inside your loop that is sending the emails, as long as you set this variable equal to the id before the movenext statement than you will have it when your recordset hits EOF.

Hope this helps,
-Tarwn ________________________________________________
Get better results for your questions: faq333-2924
Frequently Asked ASP Questions: faq333-3048
 
You could also extend the timeout of your server and command objects while you are looping through your Forwardonly recordset. ________________________________________________________________________
Are you trying to debug your ASP applications? See faq333-3255 for more details

regards,
Brian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top