Click here to Skip to main content
15,887,485 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to set and get custom properties to any file or folder (ntfs filesystem) Pin
Richard MacCutchan24-Aug-14 6:49
mveRichard MacCutchan24-Aug-14 6:49 
QuestionWindows Service Question Pin
Jassim Rahma23-Aug-14 22:03
Jassim Rahma23-Aug-14 22:03 
QuestionRe: Windows Service Question Pin
Richard MacCutchan23-Aug-14 22:43
mveRichard MacCutchan23-Aug-14 22:43 
AnswerRe: Windows Service Question Pin
Jassim Rahma23-Aug-14 22:48
Jassim Rahma23-Aug-14 22:48 
GeneralRe: Windows Service Question Pin
Eddy Vluggen24-Aug-14 0:25
professionalEddy Vluggen24-Aug-14 0:25 
GeneralRe: Windows Service Question Pin
Richard MacCutchan24-Aug-14 0:40
mveRichard MacCutchan24-Aug-14 0:40 
AnswerInconsistent names Pin
peterkmx24-Aug-14 1:01
professionalpeterkmx24-Aug-14 1:01 
GeneralRe: Inconsistent names Pin
Jassim Rahma24-Aug-14 2:02
Jassim Rahma24-Aug-14 2:02 
I completely removed the eventlog code but still having the same problem!

here is the code after modification:

C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Net.Mail;

namespace MyTestWindowsService
{
    public partial class MyTestWindowsService : ServiceBase
    {
        public MyTestWindowsService()
        {
            InitializeComponent();

            // if (!System.Diagnostics.EventLog.SourceExists("MyTestWindowsService"))
            // {
                // System.Diagnostics.EventLog.CreateEventSource("MySource", "MyNewLog");
            // }

            // eventLog1.Source = "MyEventLogSource";
            // eventLog1.Log = "MyNewLog Comes here!";
        }

        protected override void OnStart(string[] args)
        {
            // eventLog1.WriteEntry("In OnStart");
        }

        protected override void OnStop()
        {
            // eventLog1.WriteEntry("In onStop.");
        }

        protected override void OnContinue()
        {
            // eventLog1.WriteEntry("In OnContinue.");
        }

        private void timer1_Tick(object sender, EventArgs e)
        {

        }

        private void timer2_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            if (DateTime.Now.Minute == 30)
            {
                // eventLog1.WriteEntry("starting to send email.");

                try
                {
                    MailMessage mail = new MailMessage();
                    SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");

                    mail.From = new MailAddress("it@mydomain.com");
                    mail.To.Add("jassim@mydomain.com");
                    mail.Subject = "Test Mail";
                    mail.Body = "This is for testing SMTP mail from GMAIL";

                    SmtpServer.Port = 587;
                    SmtpServer.Credentials = new System.Net.NetworkCredential("it@mydomain.com", "mypassword");
                    SmtpServer.EnableSsl = true;

                    SmtpServer.Send(mail);

                    // eventLog1.WriteEntry("email sent.");
                }
                catch (Exception ex)
                {
                    // MessageBox.Show(ex.ToString());
                    // eventLog1.WriteEntry("failed sending email.");
                }
            }
        }
    }
}



Technology News @ www.JassimRahma.com

GeneralRe: Inconsistent names Pin
Wes Aday24-Aug-14 4:12
professionalWes Aday24-Aug-14 4:12 
AnswerRe: Windows Service Question Pin
Dave Kreskowiak24-Aug-14 6:55
mveDave Kreskowiak24-Aug-14 6:55 
AnswerRe: Windows Service Question Pin
Gerry Schmitz25-Aug-14 11:09
mveGerry Schmitz25-Aug-14 11:09 
QuestionSoftware Protection vs Dongle Protection Pin
Jassim Rahma22-Aug-14 5:21
Jassim Rahma22-Aug-14 5:21 
AnswerRe: Software Protection vs Dongle Protection Pin
OriginalGriff22-Aug-14 5:42
mveOriginalGriff22-Aug-14 5:42 
AnswerRe: Software Protection vs Dongle Protection Pin
Eddy Vluggen22-Aug-14 6:55
professionalEddy Vluggen22-Aug-14 6:55 
GeneralRe: Software Protection vs Dongle Protection Pin
Jassim Rahma22-Aug-14 8:01
Jassim Rahma22-Aug-14 8:01 
GeneralRe: Software Protection vs Dongle Protection Pin
Eddy Vluggen22-Aug-14 8:33
professionalEddy Vluggen22-Aug-14 8:33 
GeneralRe: Software Protection vs Dongle Protection Pin
Jassim Rahma22-Aug-14 9:32
Jassim Rahma22-Aug-14 9:32 
GeneralRe: Software Protection vs Dongle Protection Pin
Eddy Vluggen22-Aug-14 11:52
professionalEddy Vluggen22-Aug-14 11:52 
GeneralRe: Software Protection vs Dongle Protection Pin
Jassim Rahma22-Aug-14 11:54
Jassim Rahma22-Aug-14 11:54 
GeneralRe: Software Protection vs Dongle Protection Pin
Eddy Vluggen23-Aug-14 1:12
professionalEddy Vluggen23-Aug-14 1:12 
GeneralRe: Software Protection vs Dongle Protection Pin
Bernhard Hiller24-Aug-14 21:15
Bernhard Hiller24-Aug-14 21:15 
GeneralRe: Software Protection vs Dongle Protection Pin
Eddy Vluggen25-Aug-14 0:32
professionalEddy Vluggen25-Aug-14 0:32 
GeneralRe: Software Protection vs Dongle Protection Pin
jschell22-Aug-14 10:23
jschell22-Aug-14 10:23 
GeneralRe: Software Protection vs Dongle Protection Pin
Eddy Vluggen22-Aug-14 11:54
professionalEddy Vluggen22-Aug-14 11:54 
Question128 bit Decimal Type Pin
computerpublic22-Aug-14 5:01
computerpublic22-Aug-14 5:01 

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

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