Reputation: 31
I'm creating a ASP.NET .NET 4.0 website and part of this site requires that there is an "always running" application. Normally, I would create a Windows Service for this, but the site will be hosted within a shared hosting environment, and unless I get a virtual server, then this isn't a possibility.
My first thought was to have a thread running in the background that would do this and it would be created on Application_Start and destroyed on Application_End. I've looked around and this seems like it could be an option, but I would of course have to hit the site in order to cause the Application_Start to be called and if the associated AppPool is recylced, then this process would have to be repeated (so I believe?!?).
Within a normal ASP.NET website does these seem possible? I m developing an ASP.NET(with sql server) application.
Upvotes: 0
Views: 169
Reputation: 2685
First of all you should queue your emails, may be in a table in your database. Keep in mind that you can send mails through Ms Sql Server (http://technet.microsoft.com/en-us/library/ms190307.aspx) this is one option.
An other way is you can use Quartz Net scheduler. Write a MailingService class and run it by initializing quartz in your application_start event. You can configure it to run per minute and check the mail queue and try to send and if sent successfully remove from queue... Even if you recycle the application your mails won't lost because they are queued in DB.
Upvotes: 0
Reputation:
You can use ATrigger which is born to do this task. Related to your question you can check this use cases:
.Net library is also available.
Disclaimer: I was among the team who has built A Trigger. It's a freeware.
Upvotes: 1