title: How to use dependency injection in quartz.net scheduler
body: <p>I'm trying to run up quartz.net service in asp.net mvc 4 application where we are using dependency injection &amp; services. In this application I need quartz for sending emails with daily period. But whats the strange I can't use DI in quartz.net code because it's broke if I'm add constructor to it. Is anybody have any ideas how I can resolve that problem?</p>
  
  <pre><code>namespace BBWT.Web.Scheduler {
      public class EmailJob : IJob {
          //private readonly IEmailSender emailSender;
  
          //public EmailJob(IEmailSender emailSender) {
          //    this.emailSender = emailSender;
          //}
  
          public void Execute(IJobExecutionContext context) {
              var result = new List&lt;DebtorsDTO&gt;()
              {
                  new DebtorsDTO()
                  {
                      InvoiceId = 1,
                      ClientName = "Some Client",
                      ClientEmail = "someemail@mail.com",
                      ClientId = 1,
                      //SessionId = 1,
                      Date = "17.07.2015",
                      TutorName = "Tutor Tutor",
                      InvoiceName = "Invoice Name 1",
                      AgedAnalysis = "some analysis",
                      SevedDaysOverdue = 1000,
                      FourteenDaysOverdue = 0,
                      TwentyOneDaysOverdue = 0,
                      MoreThatTwentyEightDaysOverdue = 0,
                      Status = "Sent 7 day reminder",
                      IsSelectForEmail = false,
                      OnChase = true,
                      OnHold = false
                  }
              };
  
              //string[] lines = { "First line", "Second line", "Third line" };
              //System.IO.File.WriteAllLines(@"D:\Test\Test.txt", lines);
  
          }
      }
  
      public class JobScheduler {
          public static void Start() {
              // Get an instance of the Quartz.Net scheduler
              IScheduler scheduler = StdSchedulerFactory.GetDefaultScheduler();
              scheduler.Start();
  
              // Start the scheduler if its in standby
              if(!scheduler.IsStarted)
                  scheduler.Start();
  
              // Define the Job to be scheduled
              var job = JobBuilder.Create&lt;EmailJob&gt;()
                  .WithIdentity("JobMonthSchedulerSeventhDay", "IT")
                  .RequestRecovery()
                  .Build();
  
              // Associate a trigger with the Job
              var trigger = (ICronTrigger)TriggerBuilder.Create()
                  .WithIdentity("TriggerMonthSchedulerSeventhDay", "IT")
                  //.WithCronSchedule("0 0 12 7 1/1 ? *") // visit http://www.cronmaker.com/ Queues the job every minute
                  .WithCronSchedule("0 0/1 * 1/1 * ? *")
                  .StartAt(DateTime.UtcNow)
                  .WithPriority(1)
                  .Build();
  
              // Validate that the job doesn't already exists
              if(scheduler.CheckExists(new JobKey("JobMonthSchedulerSeventhDay", "IT"))) {
                  scheduler.DeleteJob(new JobKey("JobMonthSchedulerSeventhDay", "IT"));
              }
  
              var schedule = scheduler.ScheduleJob(job, trigger);
          }
      }
  
      public class EmailSenderFormDTO {
          public string Name { get; set; }
          public string Surname { get; set; }
          public string EmailTo { get; set; }
      }
  }
  </code></pre>