Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8959675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:29:39+00:00 2026-06-15T15:29:39+00:00

I am developing a windows service that sends automated e-mail in every 15 minutes.

  • 0

I am developing a windows service that sends automated e-mail in every 15 minutes. I am using a timer to use the service again after a fixed time interval (15 minutes) but its not working.

namespace Mailer
{
  public partial class Mailer : ServiceBase
  {
    System.Timers.Timer createOrderTimer;
    public Mailer()
    {
      InitializeComponent();
    }

    protected override void OnStart(string[] args)
    {
      sendmail();  //function to send email.

      createOrderTimer = new System.Timers.Timer();                      
      createOrderTimer.Elapsed += new  System.Timers.ElapsedEventHandler(createOrderTimer_Elapsed);
      createOrderTimer.Interval = 15000;
      createOrderTimer.Enabled = true;
      createOrderTimer.AutoReset = true;                      
      createOrderTimer.Start();
    }

    protected void createOrderTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs args)
    {
      createOrderTimer.Stop();
      ServiceController controller = new ServiceController("Mailer");
      controller.Start();
    }

    protected void sendmail
    {
      //code to send email.
    }

    protected override void OnStop() {  }
  }
}

Initially the email is sent but I want the email sending to be performed in every 15 minutes.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T15:29:41+00:00Added an answer on June 15, 2026 at 3:29 pm

    You need to change the code like this

    namespace Mailer
    {
      public partial class Mailer : ServiceBase
      {
        System.Timers.Timer createOrderTimer;
        public Mailer()
        {
          InitializeComponent();
        }
    
        protected override void OnStart(string[] args)
        {
          createOrderTimer = new System.Timers.Timer();                      
          createOrderTimer.Elapsed += new  System.Timers.ElapsedEventHandler(sendmail);
          createOrderTimer.Interval = 900000; // 15 min
          createOrderTimer.Enabled = true;
          createOrderTimer.AutoReset = true;                      
          createOrderTimer.Start();
        }
    
        protected void sendmail(object sender, System.Timers.ElapsedEventArgs args)
        {
          //code to send email.
        }
    
        protected override void OnStop() {  }
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing a .NET Windows service that is creating a couple of threads
I am developing large data collecting ASP.Net/Windows service application-pair that uses Microsoft SQL Server
I'm developing a Windows service which will run at a specific time every day.
I am developing a Windows service that exposes a WCF service intended to be
I'm developing and application that runs as a Windows service. There are other components
Iam developing a windows phone application that makes use of windows phone push notification
Currently developing an application for Windows Phone that makes use of the bing maps
I'm developing windows service that serves two purposes. It is a proxy to WebSphere
I'm developing a service that needs to be scalable in Windows platform. Initially it
I'm developing a windows sidebar gadget that calls out to a wcf service via

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.