Click here to Skip to main content
15,888,454 members
Home / Discussions / C#
   

C#

 
GeneralRe: Interview question: What are the 5 classes you use most often? Pin
Bastien Vandamme24-Aug-14 22:09
Bastien Vandamme24-Aug-14 22:09 
GeneralRe: Interview question: What are the 5 classes you use most often? Pin
OriginalGriff24-Aug-14 22:48
mveOriginalGriff24-Aug-14 22:48 
GeneralRe: Interview question: What are the 5 classes you use most often? Pin
OriginalGriff24-Aug-14 23:18
mveOriginalGriff24-Aug-14 23:18 
GeneralRe: Interview question: What are the 5 classes you use most often? Pin
Rob Philpott24-Aug-14 23:05
Rob Philpott24-Aug-14 23:05 
GeneralRe: Interview question: What are the 5 classes you use most often? Pin
Eddy Vluggen25-Aug-14 3:02
professionalEddy Vluggen25-Aug-14 3:02 
GeneralRe: Interview question: What are the 5 classes you use most often? Pin
jschell25-Aug-14 10:34
jschell25-Aug-14 10:34 
GeneralRe: Interview question: What are the 5 classes you use most often? Pin
Eddy Vluggen25-Aug-14 11:22
professionalEddy Vluggen25-Aug-14 11:22 
AnswerRe: Interview question: What are the 5 classes you use most often? Pin
Pete O'Hanlon24-Aug-14 23:08
mvePete O'Hanlon24-Aug-14 23:08 
GeneralRe: Interview question: What are the 5 classes you use most often? Pin
Bastien Vandamme24-Aug-14 23:34
Bastien Vandamme24-Aug-14 23:34 
AnswerRe: Interview question: What are the 5 classes you use most often? Pin
Joe Woodbury25-Aug-14 9:34
professionalJoe Woodbury25-Aug-14 9:34 
AnswerRe: Interview question: What are the 5 classes you use most often? Pin
jschell25-Aug-14 10:38
jschell25-Aug-14 10:38 
GeneralRe: Interview question: What are the 5 classes you use most often? Pin
ClimerChinna26-Aug-14 3:28
ClimerChinna26-Aug-14 3:28 
AnswerRe: Interview question: What are the 5 classes you use most often? Pin
ClimerChinna26-Aug-14 3:32
ClimerChinna26-Aug-14 3:32 
QuestionConvert image to text C# Pin
jojoba2024-Aug-14 7:00
jojoba2024-Aug-14 7:00 
GeneralRe: Convert image to text C# Pin
harold aptroot24-Aug-14 7:50
harold aptroot24-Aug-14 7:50 
AnswerRe: Convert image to text C# Pin
Pete O'Hanlon24-Aug-14 7:51
mvePete O'Hanlon24-Aug-14 7:51 
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 

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.