split arraylists into multiple arraylists?

I have a custom email campaign system that is limited to sending 200 emails per send.  I have an arraylist full or subscriber emails.  If I have a list of 407, how can I break that up into 3 or 4 seperate arrayLists?  Is this even the best way of going about this task?

Right now I have:

For i = 0 To (alSubscribers.Count()-1)
  '//get the message
  '//setup the email

  '//send the message to the first subscriber

Next i

And this works just fine, up to the 200th subscriber since my ISP restricts relays to 200 per send.

Thanks very much for your help!  If it makes a difference, I am running this on a background thread.

Thanks!
LVL 3
jayrodAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

strickddCommented:
If you want you can pause the sending after every 200 e-mails for a second.

For i = 0 To (alSubscribers.Count()-1)

  if (i MOD 200) = 0 then '//not sure of syntax for VB but it is i%200 in C#
     System.Threading.Thread.Sleep(1000)
     '//This causes a 1 second delay before moving on to the next code
     '//This means every 200 e-mails it will wait 1 second before sending another.
  end if

  '//get the message
  '//setup the email

  '//send the message to the first subscriber

Next i
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jayrodAuthor Commented:
Thanks - that seeme dto do the trick.  You even got the syntax right :)

However, this has now spawned into another (threading) question.  The list is 407 and it sent to 290 of them.  It seems that the thread was killed or died at 290.  Is there a way to check the thread in the same code that you sent to make sure it is still running, and if not - pick up where it left off?

For example I have:

For i = 0 to (alSubscribers.Count()-1)
  '//check thread
  If NOT Thread.IsAlive (or someting?) '//check the thread
    '//do something here to pickup at i value?
  End If

  If (i Mod 200) = 0 Then
     Thread.Sleep(1000)
  End If


Thanks for your help!!
0
jayrodAuthor Commented:
BTW - if you can't tell this is my first attempt at Threading!
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

jayrodAuthor Commented:
I found this - would something like this solve my problem If I do this after I start the thread:

myThread.Start()

Do While Not myThread.ThreadState = System.Threading.ThreadState.Stopped
  Thread.Sleep(100)
Loop


Thanks again!
0
strickddCommented:
The thing is you want to avoid threading as much as possible. The code I gave you just pauses the thread that is currently being processed for 1 second. If you gett into threading a .Net web application then you can encounter some serious problems/anomalies.

What is probably happening is the thread stays alive too long and times out. So if you shorten the wait time to something like:
.Sleep(200) that might help.
0
jayrodAuthor Commented:
Thanks! I will give that a try - hopefully it works!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.