Hi....
i am using a timer to invoke method and send daily mails.I kept it in Global.asax page.but its not working the timer which i had given is
myTimer.Interval = 86400000;
&
myTimer.Interval =1000*60*60*24;
i tried these two. if i kept it for 15 min it is working fine.
Thanks in advance....
Loading
Santhosh Kumar JayaramanPosted Aug 29, 2012, 8:21 AM
Create your own class like this.
public class TimerStarter
{
private static Timer threadingTimer;
public static void StartTimer()
{
if (null == threadingTimer)
{
threadingTimer = new Timer(new TimerCallback(DoActions), HttpContext.Current, 0, 8640000);
}
}
private static void DoActions(object sender)
{
// all your mail calling methods here
}
}
Then in application_start method in global.asax file.
void Application_Start(object sender, EventArgs e)
{
TimerStarter.StartTimer();
}
Let me know if you get any prob
Raj KumarPosted Oct 9, 2013, 9:42 PM
Raj KumarPosted Oct 9, 2013, 9:40 PM
Hi Santhosh Kumar Jayaraman,
Your code is not working correctly. Mean to say doesn't give expected result. I'd set timer interval at one hour. But timer doesn't run exact at one hour. Pls help me. I am uploading the result as jpg file.
BinduPosted Aug 24, 2012, 7:49 AM
{
// Code that runs on application startup
System.Timers.Timer myTimer = new System.Timers.Timer();
// Set the Interval to 5 seconds (5000 milliseconds).
myTimer.Interval = 86400000;
myTimer.AutoReset = true;
myTimer.Elapsed += new ElapsedEventHandler(myTimer_Elapsed);
myTimer.Enabled = true;
}
public void myTimer_Elapsed(object source, System.Timers.ElapsedEventArgs e)
{
// use your mailer code
ScheduleMail objScheduleMail = new ScheduleMail();
objScheduleMail.SendSurveyMailDaily();
objScheduleMail.SendSurveyMailWeekly();
objScheduleMail.SendSurveyMailMonthly();
objScheduleMail.SendCampaignMailDaily();
objScheduleMail.SendCampaignMailWeekly();
objScheduleMail.SendCampaignMailMonthly();
objScheduleMail.SendTemplatMailDaily();
objScheduleMail.SendTemplateMailsMonthly();
objScheduleMail.SendTemplateMailsWeekly();
objScheduleMail.EmailRemainders();
}
this is the code i should invoke those methods
Sukesh MarlaPosted Aug 24, 2012, 7:43 AM