Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jul 29, 2012 10:11 AM by dahla
Member
20 Points
81 Posts
Jul 29, 2012 09:43 AM|LINK
Hello bears,
I want to send bulk emails from database. I used threading as following
Thread t = new Thread(SendToRegisteredUsers); t.Priority = ThreadPriority.BelowNormal; t.Start(); void SendToRegisteredUsers() { foreach (string email in EmailList) { if (email != null) { SendEmailViaHostingServer(email.Trim()); Thread.Sleep(5000); } } }
It only sends 5 emails, then i dont know where the above thread goes. i have more than 3000 emails.
Please suggest some better code or techique.
All-Star
15346 Points
3142 Posts
Jul 29, 2012 09:48 AM|LINK
1) please check whether EmailList contains all the email ids
2) most of the hosting providers have a restriction to send out a limited amout of emails per hour many provides 100 per hour etc.
so please check with hosting provider how much is the limit
Participant
1816 Points
369 Posts
Jul 29, 2012 09:49 AM|LINK
If it throws an exception then your entire thread is stopped. I.e. email is an invalid email so the SendEmailViaHostingServer method fails...
Try debugging your way into it
Jul 29, 2012 10:00 AM|LINK
How i can debug in a thread, you mean F10. That i already did. I am sure there will be some invalid emails.
Jul 29, 2012 10:11 AM|LINK
I just missed the fact that you posted this in the asp.net section.
But first of all you need to catch any exceptions because on the first encountered exception the thread dies and will not continue or give any notice.
But you can debug it by attaching to the webprocess and then adding a breakpoint. Or pressing F5 depending on how you websolution is setup
rana-anees@h...
Member
20 Points
81 Posts
How to send Bulk Emails in ASP.NET
Jul 29, 2012 09:43 AM|LINK
Hello bears,
I want to send bulk emails from database. I used threading as following
Thread t = new Thread(SendToRegisteredUsers); t.Priority = ThreadPriority.BelowNormal; t.Start(); void SendToRegisteredUsers() { foreach (string email in EmailList) { if (email != null) { SendEmailViaHostingServer(email.Trim()); Thread.Sleep(5000); } } }It only sends 5 emails, then i dont know where the above thread goes. i have more than 3000 emails.
Please suggest some better code or techique.
Muhammad Anees
Mudasir.Khan
All-Star
15346 Points
3142 Posts
Re: How to send Bulk Emails in ASP.NET
Jul 29, 2012 09:48 AM|LINK
1) please check whether EmailList contains all the email ids
2) most of the hosting providers have a restriction to send out a limited amout of emails per hour many provides 100 per hour etc.
so please check with hosting provider how much is the limit
dahla
Participant
1816 Points
369 Posts
Re: How to send Bulk Emails in ASP.NET
Jul 29, 2012 09:49 AM|LINK
If it throws an exception then your entire thread is stopped. I.e. email is an invalid email so the SendEmailViaHostingServer method fails...
Try debugging your way into it
rana-anees@h...
Member
20 Points
81 Posts
Re: How to send Bulk Emails in ASP.NET
Jul 29, 2012 10:00 AM|LINK
How i can debug in a thread, you mean F10. That i already did. I am sure there will be some invalid emails.
Muhammad Anees
dahla
Participant
1816 Points
369 Posts
Re: How to send Bulk Emails in ASP.NET
Jul 29, 2012 10:11 AM|LINK
I just missed the fact that you posted this in the asp.net section.
But first of all you need to catch any exceptions because on the first encountered exception the thread dies and will not continue or give any notice.
But you can debug it by attaching to the webprocess and then adding a breakpoint. Or pressing F5 depending on how you websolution is setup