Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to send mails every 1 hour or user set time. How can i do and please provide some sources....
Posted
Comments
[no name] 5-Apr-12 22:51pm    
What have you tried?
Member 13661367 25-Mar-19 5:12am    
fgdfg

You can create a simple windows service that will do this for you.
Simple Windows Service Sample[^] would help you create a windows service.

Here is a simple scheduler sample - C# Scheduler[^].
 
Share this answer
 
Comments
chandanadhikari 6-Apr-12 0:21am    
useful links !! my 5!
Abhinav S 6-Apr-12 0:23am    
Thank you.
Monjurul Habib 6-Apr-12 5:15am    
5!
Abhinav S 6-Apr-12 6:30am    
Thank you Monjurul.
Hi,

you can create one application in dot net to send an email. and use Windows Task Scheduler to execute your application on given time interval.

hope this information will help you,

thanks
-Amit.
 
Share this answer
 
 
Share this answer
 
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()
    {
        // Create a timer with a ten second interval.
        aTimer = new System.Timers.Timer(60000);

        // Hook up the Elapsed event for the timer.
        aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
        aTimer.Interval = 60000*60;
        aTimer.Enabled = true;

        Console.WriteLine("Press the Enter key to exit the program.");
        Console.ReadLine();

    }

    // Specify what you want to happen when the Elapsed event is
    // raised.
    private static void OnTimedEvent(object source, ElapsedEventArgs e)
    {
        //Write code to send mail
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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900