Click here to Skip to main content
15,879,474 members
Home / Discussions / C#
   

C#

 
QuestionRe: Convert image to text C# Pin
jojoba2024-Aug-14 10:02
jojoba2024-Aug-14 10:02 
AnswerRe: Convert image to text C# Pin
Ravi Bhavnani24-Aug-14 12:25
professionalRavi Bhavnani24-Aug-14 12:25 
GeneralRe: Convert image to text C# Pin
jojoba2024-Aug-14 17:38
jojoba2024-Aug-14 17:38 
GeneralRe: Convert image to text C# Pin
Dave Kreskowiak24-Aug-14 18:32
mveDave Kreskowiak24-Aug-14 18:32 
AnswerRe: Convert image to text C# Pin
V.24-Aug-14 23:02
professionalV.24-Aug-14 23:02 
QuestionHow to set and get custom properties to any file or folder (ntfs filesystem) Pin
PatrikAb24-Aug-14 4:56
PatrikAb24-Aug-14 4:56 
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 
Hi,

I have crrated below windows service and installed it using InstallShield. I am able to see the windows service Started in the Control Panel-Services but I am not getting any email when the minutes turns to 30.

Can anyone help please...

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)
        {
            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

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

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.