Introduction
In many web application we need to send schedule(automatic) emails and we schedule them.
like:
- Sends emails on a
regular basis
- Send
the message at daily, weekly, monthly or yearly
intervals.
For this, we normally used windows services or windows
application. But in a shared host
environment you're out of luck for running these kind of application because you
don't have access on a shared server.
Background
We can perform scheduled job process through our ASP.NET web projects without buying dedicated servers.
Advantage:
1. No need to buying dedicated servers.
2. Perform scheduled job process through our ASP.NET web application.
Using the code
As we know the web server IIS is continuously running, we can add a
timer in the application and the timer can manage all these activities.
void Application_Start(object sender, EventArgs e)
{
System.Timers.Timer myTimer = new System.Timers.Timer();
myTimer.Interval = 5000;
myTimer.AutoReset = true;
myTimer.Elapsed += new ElapsedEventHandler(myTimer_Elapsed);
myTimer.Enabled = true;
}
public void myTimer_Elapsed(object source, System.Timers.ElapsedEventArgs e)
{
clsScheduleMail objScheduleMail = new clsScheduleMail();
objScheduleMail.SendScheduleMail();
}
public void SendScheduleMail()
{
}
For more details, please refer to the uploaded code.