c# - How to Send Mail at 10 AM every using hangfire scheduler library ASP.NET Web Forms -


how send mail @ 10 automatically every day using hangfire scheduler library , installed hangfire dll also.

below c# code.

protected void page_load(object sender, eventargs e) {     if (!ispostback)     {         backgroundjob.schedule(           () => sendmail1(),           new datetime(2017, 03, 27, 10, 00, 00));         }     } }  public void sendmail1() {    //mailer content } 

please out issue send 10 every day , if other way helpful.

your requirement send email everyday 10 means it's recurring task want schedule. case backgroundjob class not 1 should use. need use recurringjob class.

if visit http://hangfire.io/ can located easily.

further exploration handfire library classes have explained methods available recurringjob class.

recurringjob class has method addorupdate , 1 of overloads takes 4 arguments out of last 2 optional.

public static void addorupdate(expression<func<task>> methodcall, string cronexpression, timezoneinfo timezone = null, string queue = "default"); 

if notice, cronexpression nothing string. need figure out string represents cron expression daily 10am schedule.

http://www.quartz-scheduler.org/documentation/quartz-2.x/tutorials/crontrigger.html

this link has ready use examples of cron expressions , 1 of them 0 0 12 * * ? means daily 12 (noon).

you change 0 0 10 * * ? cron expression daily 10am schedule.

and code should following.

protected void page_load(object sender, eventargs e) {     if (!ispostback)     {         recurringjob.addorupdate(() => sendmail1(), "0 0 10 * * ?");     } } 

this should resolve issue.

little bit of reading , exploration have saved 10 hours of time.


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -