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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Amit ChoudharyRank #145 · 15.8K reputationPosted Jan 17, 2011, 10:57 PM EST
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
ShankeyRank #972 · 2.1K reputationPosted Jan 17, 2011, 8:17 PM EST
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/
Vikas AhlawatRank #2,648 · 525 reputationPosted Jan 17, 2011, 8:48 PM EST
Vikas AhlawatRank #2,648 · 525 reputationPosted Jan 18, 2011, 12:03 AM EST
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.Amit ChoudharyRank #145 · 15.8K reputationPosted Jan 18, 2011, 1:56 AM EST
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
Mahesh ChandRank #1 · 393.3K reputationPosted Jan 18, 2011, 2:23 AM EST
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.
Vikas AhlawatRank #2,648 · 525 reputationPosted Jan 18, 2011, 2:45 AM EST
Can you suggest me the best solution for this problem.
any ex etc?
Suthish NairRank #92 · 22.8K reputationPosted Jan 18, 2011, 11:45 PM EST
Vikas AhlawatRank #2,648 · 525 reputationPosted Jan 21, 2011, 11:35 PM EST
any reply??
Suthish NairRank #92 · 22.8K reputationPosted Jan 23, 2011, 12:21 AM EST