Click here to Skip to main content
15,886,963 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
First of all, im not spamming. I want to write an application, sending large volumes of email for financial companies - for sending information emails.

The application will be windows forms or windows service (sending emails saved in db).
What is the best way (not the easiest), to do that?
Posted

 
Share this answer
 
Comments
ambarishtv 22-May-11 8:39am    
my5 :)
Espen Harlinn 22-May-11 11:27am    
Nice links, my 5
First off you have to have a "storage" for emails.
It could be a message queueu or database.
Do not try to send large number of eamils in a loop - it will not work.
Then, you need a windows service.
The service will wake up, say every 30 seconds (you may and should write an algorithm for how often the service wakes up depending on the number of emails waiting to be sent), query the "storage" for say next 100 emails (I am using 100 but this still could be optimizied), send emails and go into sleep. You can enhance the service by defining email server(s) in .config file and loading their data on service "OnStart" method. If you have more than one email service you could create a separate thread for each and divide email batch (our 100 items) between threads.
Also, keep in mind that email server may have a limit on number of emails sent from single IP address; this is to defend against spamming.
You will have to make sure that this is not affecting your service.
Last but not least, to make the service robust, it may make sense to add additional message queue or db table for eamils which where not send due to some errors. The service would have a separte method which could get
triggered say every 15 minutes to peek at these problem emails and attempt to send it again.
 
Share this answer
 
Use System.Net.Mail namespace and utilize any classes that are associated with mail functionality.E.g can be found here from MSDN MailMessage Class[^]

I hope this will help you well.
 
Share this answer
 
The application will be windows forms or windows service (sending emails saved in db).
Windows Service.

If needed, Sample:
Simple Windows Service which sends auto Email alerts[^]

MSDN: Details about Windows Service:
Introduction to Windows Service Applications[^]
 
Share this answer
 
Comments
Wonde Tadesse 21-May-11 14:07pm    
Mr. Sandeep the first sample is developed by obsolete namespace[Syste.Web.Mail]. It might not be good example.

http://weblogs.asp.net/dfindley/archive/2006/04/23/Migrating-from-System.Web.Mail-to-System.Net.Mail.aspx

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900