I am getting the following error when I try to start the windows service I have written:
ReadOutlookService on local computer started and then stopped.Some services stop automatically if they have no work to do, for example the Performance logs and alerts service.
My Service.cs contains the following:
Expand|Select|Wrap|Line Numbers
- protected override void OnStart(string[] args)
- {
- // TODO: Add code here to start your service.
- eventLog1.WriteEntry("ReadOutLookService OnStart");
- tm.Enabled = true;
- //tm.Start;
- tm.Elapsed += new ElapsedEventHandler(Timer_Elapsed);
- }
- protected void Timer_Elapsed(object sender,
- System.Timers.ElapsedEventArgs e)
- {
- try
- {
- //eventLog1.WriteEntry("Timer started");
- _Application olApp = new ApplicationClass();
- _NameSpace olNs = olApp.GetNamespace("MAPI");
- MAPIFolder oInbox = olNs.GetDefaultFolder(OlDefaultFolders.olFolderInbox);
- Items oItems = oInbox.Items;
- for (int i = 1; i <= oItems.Count; i++)
- {
- _MailItem oMail = (_MailItem)oItems.Find("DTE Time Reminder");
- oMail.Display(false);
- }
- }
- catch (System.Exception ex)
- {
- throw (ex);
- }
- }
Thanks in advance,
mrk