My requirement is, i need to check database date time value if current time is above the 30 minutes i need to send mail to user. How i achieve this. If it by windows service
you put a timer in your windows service below like :
protected override void OnStart(string[] args)
{
log.Info("Info - Service Started");
_timer = new Timer(30 * 60 * 1000); // every 30 minutes
_timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
_timer.Start(); // <- important
}
private void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
//here select your data from database
//then check database time with current time
//finally sens email
}
also for check time , you can use below code :
var min= (dbDateTime.TimeOfDay - DateTime.Now.TimeOfDay).TotalMinutes;
Member
35 Points
156 Posts
Send mail to user every 30 minute
Apr 02, 2018 03:33 PM|binustrat|LINK
Hi all,
My requirement is, i need to check database date time value if current time is above the 30 minutes i need to send mail to user. How i achieve this. If it by windows service
how i write and implement this?
Star
8119 Points
2778 Posts
Re: Send mail to user every 30 minute
Apr 02, 2018 04:06 PM|vahid bakkhi|LINK
hi
you put a timer in your windows service below like :
also for check time , you can use below code :
Please MARK AS ANSWER if suggestion helps.
None
0 Points
2 Posts
Re: Send mail to user every 30 minute
Apr 03, 2018 12:49 PM|anuvk|LINK
Hi Binustrat,
Another option would be reading the time from database initially and creating a Task Scheduler or Daily Trigger for the same functionality.
Please check the feasibility with your scenario.
Regards,
anu