tags:

views:

20

answers:

2

Hi,

I'm using ASP code and AspEmail component to send emails to our clinets, but I have some problmes...

I have more then 1000 email address that I need to send them an email, becuase of my SMTP provider limitation, I can't add them all as BCC in one email but I need to send each email seperatly, therefor looping on +1000 times witch takes forever and fires the server timeout error.

I need to send those emails about 20 times a day.

This is my script:

 on error resume next

 msg = "SOME TEXT HERE" 


 Set Mail = Server.CreateObject("Persits.MailSender")

 Mail.Host = "SMPT.HOST.ADDRESS" 
 Mail.Port = 25    

 Mail.CharSet = "UTF-8"
 Mail.ContentTransferEncoding = "Quoted-Printable"

 Mail.From =  "[email protected]"

 MailSubject = "email subject"

 Mail.Subject = Mail.EncodeHeader(MailSubject, "utf-8")

 Mail.Body = msg

 Mail.IsHTML = True


 zBcc = split(zBcc, ";") '1000 emails here

 for i=0 to Ubound(zBcc)
  zBcc(i) = trim(zBcc(i))
  if len(zBcc(i))>0 then
   if inStr(zBcc(i), " ")>0 then

   else
    if (Mail.ValidateAddress(zBcc(i)) = 0) then

     Mail.Reset() 
     Mail.AddAddress zBcc(i)
     Mail.Send

    end if

   end if
  end if
 next

 set Mail=nothing
A: 

why dont you do it using a pagination type logic i.e. limit by 100, loop thru that batch, once that has completed, reload the page with the next offset in mind like send-email.asp?offset=100, send-email.asp?offset=200, etc. use that offset value to get next batch repeat process until end of recordset.

At least you have less chance of it timing out altho you can increase it: server.ScriptTimeout = 180

PHPology
A: 

First of all I'd maximize the number of BCC's per cycle. Let's say you can email 50 BCC's in one go; you should: especially when you need this page about 20 times a day.

Anyway. Before you start; maximize the scripttimeout

Server.ScriptTimeout = 2147483647 
riffnl