I have complete code for send daily mail to expiration mail to user. my description of code is below:
Global.asax :
void Application_Start(object sender, EventArgs e)
{
System.Timers.Timer myTimer = new System.Timers.Timer();
double inter = (double)GetNextInterval();
myTimer.Interval = inter;
myTimer.AutoReset = true;
myTimer.Elapsed += new ElapsedEventHandler(myTimer_Elapsed);
myTimer.Enabled = true;
}
private double GetNextInterval(){
string timeString;
timeString = "12:00 AM";
DateTime t = DateTime.Parse(timeString);
TimeSpan ts = new TimeSpan();
int x;
ts = t - System.DateTime.Now;
if (ts.TotalMilliseconds < 0)
{
ts = t.AddDays(1) - System.DateTime.Now;
}
return ts.TotalMilliseconds;
}
public void myTimer_Elapsed(object source, System.Timers.ElapsedEventArgs e)
{
// My Mail Code
}
This code is work for first time mail but i want to daily basis send mail.
How it possible?