Click here to Skip to main content
Licence CPOL
First Posted 2 Jan 2010
Views 18,680
Downloads 1,042
Bookmarked 30 times

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

By | 2 Jan 2010 | Article
Send schedule(automatic) emails through ASP.NET web application.

Introduction

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

  • 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.

Background 

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

Advantage:
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();
        objScheduleMail.SendScheduleMail();   
    }
   // inside your class
    public void SendScheduleMail()
    { 
      // Write your send mail code here.
    } 
For more details, please refer to the uploaded code.

License

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

Member

Hi, I am Samrat Banerjee from India.
I am a Software Engineer working in .net platform.
I love to explore new technologies.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
Questionsend mail on cache item expires in asp.net Pinmemberpranaysoni007821:03 19 May '12  
Questionhow to use this class file with database Pinmembersathya.spidy20:53 1 Apr '12  
GeneralMy vote of 4 PinmemberRicha.Net1:35 8 Nov '11  
QuestionNot Working PingroupTechnoses1:31 8 Oct '11  
GeneralHelp Required Pinmembersyed_developer1:38 31 Jan '10  
Generalhttp://msdn.microsoft.com/en-us/library/ms525334.aspx PinmemberMoPhat1:11 4 Jan '10  
GeneralRe: http://msdn.microsoft.com/en-us/library/ms525334.aspx PinmemberMember 116262917:03 7 Jan '10  
GeneralMy vote of 1 PinmemberVirendra Dugar22:55 3 Jan '10  
GeneralThanks but ! Pinmemberatarikg13:10 2 Jan '10  
GeneralBad solution PinmemberPuchko Vasili8:26 2 Jan '10  
GeneralRe: Bad solution PinmemberSpunkybabe23:53 2 Aug '11  
GeneralNeeds some meat PinmemberAxel Rietschin7:21 2 Jan '10  

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.

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