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 8626243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:58:40+00:00 2026-06-12T07:58:40+00:00

I’m trying to use a timer to send an email every minute. The information

  • 0

I’m trying to use a timer to send an email every minute. The information for each email is taken from values for each row of components I have on a form. I can send the emails without using the timer, so I know the email method works. But when I try to implement the timer, the emails do not get sent. I read the docs on the timer class, and I believe this should work. But I’m not familiar with it enough to really know what to do. Here is the code:

Here is the email method:

//method to send email to outlook
public void sendEMailThroughOUTLOOK(string recipient, 
    string subject, string body)
{        
    try
    {    
        // Create the Outlook application.
        Outlook.Application oApp = new Outlook.Application();
        // Create a new mail item.
        Outlook.MailItem oMsg = 
            (Outlook.MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);
        // Set HTMLBody. 
        //add the body of the email
        oMsg.Body = body;

        oMsg.Subject = subject;
        // Add a recipient.
        Outlook.Recipients oRecips = (Outlook.Recipients)oMsg.Recipients;
        // Change the recipient in the next line if necessary.
        Outlook.Recipient oRecip = (Outlook.Recipient)oRecips.Add(recipient);
        oRecip.Resolve();
        // Send.
        oMsg.Send();
        // Clean up.
        oRecip = null;
        oRecips = null;
        oMsg = null;
        oApp = null;
    }//end of try block
    catch (Exception ex)
    {
    } //end of catch
} //end of Email Method

And here is the timer event:

private void OnTimedEvent(object source, ElapsedEventArgs e)
{
    foreach (rowClass row in this.rows)
    {
        string recipientAddress = "roomcheckstest@gmail.com";
        string subjectLine = "GPC " + (string)row.buildingComboBox.SelectedItem
            + " " + (string)row.roomComboBox.SelectedItem + "-Room Check";
        string senderline = "Sender=ctsstaff.ithelpcentral@ttu.edu" + "\t";
        string newlinespaces = Environment.NewLine + Environment.NewLine +
            Environment.NewLine + Environment.NewLine + Environment.NewLine;
        string legalLastName = "Legal Last Name=" + 
            (string)row.buildingComboBox.SelectedItem;
        string legalFirstName = "Legal First Name=" + 
            (string)row.roomComboBox.SelectedItem;
        string timeLine = "Time= 15m";
        string requestType = "Initial Request Type=Onsite";
        string classRoomMaintenace = "Classroom maintenance. " +
            "Regular Classroom weekly check.";
        string closingEmailSent = "Closing Email Sent=yes";
        string currentlyClosed = "Currently Closed=yes";
        string assignTo = "Assign To=ITHC CTS Staff";
        string typeLine = "Type=Hardware";
        string category = "Category=Internal Component";
        string subCategory = "Subcategory=Performance";
        string agentType = "Type (Agent)=Hardware";
        string agentCategory = "Type (Agent)=Hardware";
        string subCategoryAgent = "Subcategory (Agent)=Performance";
        string labelLine = "Label=Service Request";
        string status = "Status=Closed";
        string finalbody = senderline + newlinespaces + legalLastName 
            + newlinespaces + legalFirstName + newlinespaces + timeLine 
            + newlinespaces + requestType + newlinespaces + classRoomMaintenace 
            + newlinespaces + closingEmailSent + newlinespaces 
            + currentlyClosed + newlinespaces + assignTo + newlinespaces 
            + typeLine + newlinespaces + category + newlinespaces 
            + subCategory + newlinespaces + agentType + newlinespaces 
            + agentCategory + newlinespaces + subCategoryAgent 
            + newlinespaces + labelLine + newlinespaces + status;
        sendEMailThroughOUTLOOK(recipientAddress, subjectLine, finalbody);
        MessageBox.Show("email");
        //Thread.Sleep(60000);
        //sendEMailThroughOUTLOOK(recipientAddress, subjectLine, finalbody);
    }       
}

Here is where the timer is created inside a send email button on the form, which should in theory call the email method:

private void submitButton_Click(object sender, EventArgs e)
{
    if (rows[0].buildingComboBox.SelectedIndex > -1)
    {
        System.Timers.Timer time = new System.Timers.Timer();
        time.Interval = 300000;
        time.Enabled = true;
        time.Elapsed += new ElapsedEventHandler(OnTimedEvent);

        MessageBox.Show("Issues Sent");
    }
}

I send an email for each row of components on the form (the user adds rows as needed)
The email is sent through outlook (it has to be sent through outlook using exchange server)
I need to delay it because the server will not accept them all at once. My understanding of the timer class must be flawed. I cant figure out why this isn’t working.

  • 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-12T07:58:42+00:00Added an answer on June 12, 2026 at 7:58 am

    It looks like you need to call .Start() on the Timer.

    Note that nothing will happen until the timer ticks, so the first e-mail won’t go out immediately.

    Also, your timer interval is set to 5 minutes (300,000ms) instead of 1 (60,000ms).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I have a view passing on information from a database: def serve_article(request, id): served_article
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I want use html5's new tag to play a wav file (currently only supported

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.