My application is a asp.net 3.5 running on iis 6 (windows 2003) This application is serving 1000's of users daily (100-500 users online).
I want to send an email newsletter to customers weekly.
Around 200,000 emails every time.
This is the code im using:
ThreadPool.QueueUserWorkItem(new WaitCallback(AsyncProcessMailerQueue), null);
private static void AsyncProcessMailerQueue(object data)
{
for (int i=0;i<users.count ; i++)
{
MailMessage message = new MailMessage();
.......
SmtpClient smtpClient = new SmtpClient();
smtpClient.Send(message);
}
}
When testing this locally (on my dev machine) i see the application is working alot slower.
- Is there a better way to write this code?
- Should i use ThreadPool.QueueUserWorkItem or create a new thread using Thread t = new Thread(new ThreadStart(DoWork)); ?
- Will it be better to create a totally seperate application for the purpose of sending the newsletters. will that help if ill run this application on the same machine?
i've seen other posts here talking about ThreadPool vs Thread but its seem no one is sure which is better.
Any information is welcome! Thank You!