Hi
I want to fire an event in my asp.net application on specific time.
For ex:- I want to send email to my clients on 8 Am (every day).
How can i do this?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Amit ChoudharyPosted Jan 18, 2011, 3:57 AM
If you are using SQL Server then there's an option for creating jobs and schedule you can try that by creating a job and schedule it for specific time to send the email's.
In asp.net you can write code in Application Event in global.asax for checking the time and send the mail. create a while loop that checks for time and if it comes to your specific time then call the function that sends the mails.
Hope this helps you.
Thanks
Suthish NairPosted Jan 23, 2011, 5:21 AM
Vikas AhlawatPosted Jan 22, 2011, 4:35 AM
any reply??
Suthish NairPosted Jan 19, 2011, 4:45 AM
Vikas AhlawatPosted Jan 18, 2011, 7:45 AM
Can you suggest me the best solution for this problem.
any ex etc?
Mahesh ChandPosted Jan 18, 2011, 7:23 AM
For this kind of work, I would not do in a Web application. If you just need to send autmatic notifications every day at 8:00 AM, either create a console application and set it as a job on the server or create a Windows service. You can also use SQL Server (if you are using SQL Server) to do the same.
Amit ChoudharyPosted Jan 18, 2011, 6:56 AM
why you want to break through the loop if you have to send the mail everyday as scheduled task?
and if you want to redirect to some page then try Http.CurrentContext.Response.Redirect(); see if it works..
i'll look around if i can found best solution for you with what i understood your problem.
Thanks
Vikas AhlawatPosted Jan 18, 2011, 5:03 AM
I m using following code but how can break through loop?
Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup while (true){
try{
if ((DateTime.Now.Hour == 15) && (DateTime.Now.Minute == 21) && (DateTime.Now.Second == 0)){
System.Net.Mail.
MailMessage mailtosend = new System.Net.Mail.MailMessage();mailtosend.To.Add(
"[email protected]"); //Response.Write("The id added " +mailtosend);mailtosend.From =
new System.Net.Mail.MailAddress("rmailtosend.Subject =
"Cutch Tele Login Reports as of ";mailtosend.IsBodyHtml =
true;mailtosend.Body =
"hwebwhbrej";System.Net.Mail.
SmtpClient sc = new System.Net.Mail.SmtpClient();sc.Host =
"mail.cutchsoft.com";sc.Credentials =
new System.Net.NetworkCredential("sc.Send(mailtosend);
}
}
//if check catch (Exception ee){
//ClientScript.}
}
//while}
and when i putting response.redirect it give error.Vikas AhlawatPosted Jan 18, 2011, 1:48 AM
ShankeyPosted Jan 18, 2011, 1:17 AM
you can use timer control with your wished interval time and can use timer_Tick event to achieve what you want.
For your Reference
http://ajax.net-tutorials.com/controls/timer-control/