I have a windows service to send emails every night at 12am.
I want it to start and stop it with the help of a windows task scheduler.
I thought using Windows Start Scheduler may be the best option and run the windows service using a bat file like - NET START "Myservice".
But, after it runs for the first day, it does not stop.
How can I make it stop after completing the email sending process?
Is using Windows Task scheduler better than thread for services running once a day?
Anand UchagawkarPosted Oct 21, 2012, 11:25 AM
r pPosted Oct 3, 2012, 10:52 AM
How do I create a log which I can check once in a week to make sure emails are sent properly or whether there was any error in connecting to the SQL database etc.
r pPosted Oct 3, 2012, 10:46 AM
It sounds like a better idea than using Service.
I will try it.
Cheers
Anand UchagawkarPosted Oct 3, 2012, 10:21 AM
If you want to have emails to be sent every night at 12am then I would not recommend you to have Windows service to send the emails. As what you want to achieve is,
- A program which would send an email whenever it is invoked
- A scheduler which would call the email program
For this, instead of Windows service i would recommend you to use a simple Console application and embeed the email sending logic in that.Then as you call the bat file for starting the service, in similar manner instead of NET START "your service" just call the exe "PATH\testemail.exe" from the batch file.
After the exe has completed it's job of sending email it would automatically get stopped and no seperate logic is required for that.