Create a
windows service
, add a
Timer
with time interval as 60000*60. On the
Elapsed
or
Tick
event of the timer write he code to send mail.
private static System.Timers.Timer aTimer;
public static void Main()
{
aTimer = new System.Timers.Timer(60000);
aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
aTimer.Interval = 60000*60;
aTimer.Enabled = true;
Console.WriteLine("Press the Enter key to exit the program.");
Console.ReadLine();
}
private static void OnTimedEvent(object source, ElapsedEventArgs e)
{
MailMessage mm = new MailMessage();
mm.BodyFormat = MailFormat.Html;
mm.To = dr["emp_email"].ToString();
mm.From = "xyz@xyz.com";
mm.Subject="Good Day";
mailtxt = "<font face="verdana" color="#FF9900">"+"Hi "+dr["emp_name"].ToString()+"," + "</font><br><br>";
mailtxt=mailtxt+"<font face="verdana" color="#FF0000">"+"Good Day." + "</font><br><br>";
mailtxt=mailtxt+"<font face="verdana" color="#008080">"+"May today be filled with sunshine and smile, laughter and love." + "</font><br><br>";
mailtxt=mailtxt+"<font face="verdana" color="#0000FF">Cheers!" + "<br><br>";
mm.Body = mailtxt;
SmtpMail.SmtpServer="localhost";
SmtpMail.Send(mm);
}
</br></br></font></br></br></br></br></br></br>
follow
this[
^] link