how can i send emails automatically in asp.net using C# code
-
hello every one... plzz.. help me .. actually i want 2 send emails automatically at a particular time how can i do this ..plzz..help me...
thanks 2 all..
-
hello every one... plzz.. help me .. actually i want 2 send emails automatically at a particular time how can i do this ..plzz..help me...
thanks 2 all..
Use a service (windows or web) with a timer. When the timer reaches the particular time needed send the emails by using the System.Net.Mail.MailMessage class.
I am fighting against the Universe... Reference-Rick Cook
-
Use a service (windows or web) with a timer. When the timer reaches the particular time needed send the emails by using the System.Net.Mail.MailMessage class.
I am fighting against the Universe... Reference-Rick Cook
but how can i do ..plz..send me code brother......if u have or give me any sugession..
thanks 2 all..
-
but how can i do ..plz..send me code brother......if u have or give me any sugession..
thanks 2 all..
I have used this approach in a project of mine . I created a windows service and by default this will give you 2 event handlers : OnStart & OnStop. In the OnStart you could do something like this :
protected override void OnStart(string\[\] args) { //a handle for the Elapsed event Alarm.Elapsed += new ElapsedEventHandler(OnElapsedTime); //set the interval between 2 consecutive Elapsed events Alarm.Interval = SETINTERVAL; // a constant equal to 60000 ms //enabling the timer Alarm.Enabled = true; }
The "alarm" object is an instance of System.Timers.Timer class. In the OnElapsedTime event you can check to see if the time has come to send the mails and call the appropiate method. As for the MailMessage class and how to use it I suggest using Google for the answer.
I am fighting against the Universe... Reference-Rick Cook
-
hello every one... plzz.. help me .. actually i want 2 send emails automatically at a particular time how can i do this ..plzz..help me...
thanks 2 all..
use system.net.mail namespace MailAddress SendFrom = new MailAddress(txtFromAddr.Text); SmtpClient objSmtpClient = new SmtpClient(); objSmtpClient.Host = "mail.techgene.net"; objSmtpClient.Credentials = new System.Net.NetworkCredential("uname", "pwd"); MailAddress SendTo = new MailAddress(_mailId); MailMessage objMailMessage = new MailMessage(SendFrom, SendTo); objMailMessage.Subject = Convert.ToString(txtSubject.Text); objMailMessage.Body = Convert.ToString(webBrowser1.DocumentText); objMailMessage.IsBodyHtml = true; objSmtpClient.Send(objMailMessage); G. Satish
-
I have used this approach in a project of mine . I created a windows service and by default this will give you 2 event handlers : OnStart & OnStop. In the OnStart you could do something like this :
protected override void OnStart(string\[\] args) { //a handle for the Elapsed event Alarm.Elapsed += new ElapsedEventHandler(OnElapsedTime); //set the interval between 2 consecutive Elapsed events Alarm.Interval = SETINTERVAL; // a constant equal to 60000 ms //enabling the timer Alarm.Enabled = true; }
The "alarm" object is an instance of System.Timers.Timer class. In the OnElapsedTime event you can check to see if the time has come to send the mails and call the appropiate method. As for the MailMessage class and how to use it I suggest using Google for the answer.
I am fighting against the Universe... Reference-Rick Cook
plzz tell me how can i create windows service.. even i m doing on webapplication ..is it workin in web application..wht u given code 4 me..plzz tell me..brother..
thanks 2 all..