Maybe someone needs this code for Asp.net webform.
EmailJob Code
public class EmailJob : IJob
{
public void Execute(IJobExecutionContext context)
{
sendmail();
}
public void sendMail()
{
//send mail code
}
}
JobScheduler code working 00.00 for every day. you can change what you want.. :)
public class JobScheduler
{
public static void Start()
{
IScheduler scheduler = StdSchedulerFactory.GetDefaultScheduler();
scheduler.Start();
IJobDetail job = JobBuilder.Create<EmailJob>().Build();
ITrigger trigger = TriggerBuilder.Create()
.WithDailyTimeIntervalSchedule
(s =>
s.WithIntervalInHours(24)
.OnEveryDay()
.StartingDailyAt(TimeOfDay.HourAndMinuteOfDay(00, 00))
.InTimeZone(TimeZoneInfo.Local)
)
.Build();
scheduler.ScheduleJob(job, trigger);
}
}
Global.asax start jobscheduler
void Application_Start(object sender, EventArgs e)
{
JobScheduler.Start();
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…