i’m ASP.NET programmer and have no experience in creating windows services.
Service i need to create should send emails to our customers each specified period of time. This service should solve issue when hundreds of emails are sent at the same time and block SMTP service on the server while there are many periods of time when SMTP is on idle without sending anything.
Idea is to create a service that i will send whole email and address to, inside of the service i will have some type of dataset ( i don’t know which one should i use in winforms/winservices) and some basic timer functionality (ie. each 3 seconds get first mail and send it)…
Thing is that there are two main types of mails, registration mails which should be main priority and reminder mails (ie. you haven’t entered a site for month ) which have low priority. I prefer to create this priority issue with two data sets, when main one is empty less important one sends.
Another issue is how do i access this service from asp.net application on the same server?
How would you write that in code or at least point me how to, i know there are many explanations on MS website on basic services but as i don’t know much about issue i prefer having it explained in here.
Thanks for your time.
First of all, you don’t need a windows service at all, if you know how to send an e-mail from your asp.net app. Read on…
I had a problem similar to yours because ISP that I had my site on was having a limit on e-mails that it can deliver in a day. So I created database table with e-mails, and stored them in there, and created one web page that checked the limits that are in effect, determined if it’s safe to send an e-mail, and sends it if it is.
After sending (or not sending) – that page slept for a while (you can insert Sleep() into it – don’t use any loops because it will consume your CPU) and then triggered itself via http request again, if there is more mail to be sent.
Every page that filled the mail queue also triggered mail sending page, so it doesn’t run when queue is in fact empty.
I guess, either that, or you really go for services.