Search code examples
c#threadpoolbulk-mail

Sending millions of Mails using ThreadPool


I have more than 100 million Mail IDs in my MySQL Database. I need to send E-Mails which is in HTML format to all those Mail IDs using thread pool. I cannot take that much datas in a single DataTable. So I think I can take 1000 Datas and after sending those 1000 Mails again take the next 1000. In that way I need to complete the Mailing Operation. I'm using 'MySql.Data.MySqlClient' for communicating with MySQL Database

My Database Structure is

Columns: ID - bigint, MailID - varchar(300), Unsubscribed - bit

I need to send mails to all Mail IDs with value 0 in Unsubscribed column.

Please help me how to do it in C#.


Solution

  •  SELECT * FROM Mails WHERE Unsibscribed=0 LIMIT 0,1000
     SELECT * FROM Mails WHERE Unsibscribed=0 LIMIT 1000,1000
     ...
    

    see http://dev.mysql.com/doc/refman/5.0/en/select.html especially LIMIT clause.

    also http://php.about.com/od/mysqlcommands/g/Limit_sql.htm