Click here to Skip to main content
11,410,750 members (64,034 online)
Click here to Skip to main content

Schedule Email Through ASP.NET or Schedule Tasks Using ASP.NET

, 2 Jan 2010 CPOL
Rate this:
Please Sign up or sign in to vote.
Send schedule(automatic) emails through ASP.NET web application.


 In many web application we need to send schedule(automatic) emails and we schedule them.

  • Sends emails on a regular basis
  • Send the message at daily, weekly, monthly or yearly intervals.  
  For this, we normally used windows services or windows application.

  But in a shared host environment you're out of luck for running these kind of application because you  don't  have access on a shared server.


We can perform scheduled job process through our ASP.NET web projects without buying dedicated servers.

1. No need to buying dedicated servers.
2. Perform scheduled job process through our ASP.NET web application. 

Using the code 

As we know the web server IIS is continuously running, we can add a timer in the application and the timer can manage all these activities.   

    // Inside Global.ascx 
    void Application_Start(object sender, EventArgs e) 
        // Code that runs on application startup
        System.Timers.Timer myTimer = new System.Timers.Timer();
        // Set the Interval to 5 seconds (5000 milliseconds).
        myTimer.Interval = 5000;
        myTimer.AutoReset = true;
        myTimer.Elapsed += new ElapsedEventHandler(myTimer_Elapsed);
        myTimer.Enabled = true; 

    public void myTimer_Elapsed(object source, System.Timers.ElapsedEventArgs e)
        // use your mailer code 
        clsScheduleMail objScheduleMail = new clsScheduleMail();
   // inside your class
    public void SendScheduleMail()
      // Write your send mail code here.
For more details, please refer to the uploaded code.


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


About the Author

Samrat Banerjee
Software Developer (Senior) Viscus Infotech Ltd. [India]
India India
Hi, I am Samrat Banerjee from India.
I am a Software Engineer working in .net platform.
I love to explore new technologies.

Comments and Discussions

QuestionSame code but dosnt work Pinmembervezo1124-Jun-14 6:21 
QuestionMessage Removed Pinmembervezo1122-Jun-14 9:39 
QuestionVery Nice article ...... Pinmemberheemanshubhalla15-Feb-14 8:01 
AnswerRe: Very Nice article ...... PinmemberSamrat Banerjee1-Mar-14 0:42 
Question[My vote of 1] its not working i have tested on my shared hosting Pinmembersamiatcodeproject17-Sep-13 3:09 
GeneralMy vote of 5 PinmemberMember 97250354-Jul-13 0:35 
QuestionHow to send mail at specific time? PinmemberChanchal Purbia3-Mar-13 21:57 
You article is very nice.....
Is it possible to send email at specific time (eg. 12:01 am) without using windows service???
Mail to be send contains data from database...
if u know solution, plz help....
GeneralMy vote of 1 Pinmemberhemantrautela29-Dec-12 3:55 
GeneralMy vote of 1 Pinmemberaspnet_regiis -i21-Nov-12 3:12 
GeneralMy vote of 5 Pinmemberjayantj13-Oct-12 4:20 
GeneralMy vote of 1 PinmemberMember 92790763-Aug-12 6:27 
GeneralMy vote of 5 Pinmembertanweer akhtar29-Jun-12 1:33 
GeneralMy vote of 5 PingroupHari Chowdary13-Jun-12 23:56 
Questionsend mail on cache item expires in Pinmemberpranaysoni007819-May-12 22:03 
Questionhow to use this class file with database Pinmembersathya.spidy1-Apr-12 21:53 
AnswerRe: how to use this class file with database PinmemberVenkata Aditya Korada7-Sep-12 8:40 
GeneralMy vote of 4 PinmemberRicha.Net8-Nov-11 2:35 
QuestionNot Working PingroupTechnoses8-Oct-11 2:31 
GeneralHelp Required Pinmembersyed_developer31-Jan-10 2:38 
General PinmemberMoPhat4-Jan-10 2:11 
GeneralRe: PinmemberMember 11626297-Jan-10 18:03 
GeneralMy vote of 1 PinmemberVirendra Dugar3-Jan-10 23:55 
GeneralThanks but ! Pinmemberatarikg2-Jan-10 14:10 
GeneralRe: Thanks but ! PinmemberVenkata Aditya Korada13-Sep-12 15:27 
GeneralBad solution PinmemberPuchko Vasili2-Jan-10 9:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.150414.5 | Last Updated 2 Jan 2010
Article Copyright 2010 by Samrat Banerjee
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid