I am doing a c# Winform application which automatically sends 2 types of e-mails :
The first group of mail must be sent only on Mondays (weekly), at 9am, the second group of email must be sent only the 1st day of every month (monthly).
Currently i'm doing this
if (day_event == "monday" && DateTime.Now.Hour.ToString() == heuresortiehebdo)
{
//starting first group of mails
}
else if(DateTime.Now.Day==1 && DateTime.Now.Hour.ToString() == heuresortiemensuels)
{
//starting 2nd group of mails
}
(heuresortiehebdo and heuresortiemensuels are variables which are set from APP.config file, it is the hour set for sending each group of mails)
So this solution works for 1 time, but the goal is to let the application open and never stop it, send automatically mails when it's time and hour. I've thought about threads but how to check everytime if it is the good day and good hour ? Without using windows task scheduler.