0

Suppose I have an entity:

    public class Appointment
    {
        public DateTime AppointmentDateTime {get;set}
        public string CustomerName {get;set;}
        public string CustomerEmail {get;set;}
    }

How can I schedule an email to be sent to customer 2 Hours before AppointmentDateTime Automatically? Also is it possible to reschedule the email time when AppointmentDateTime is changed?

Lokesh Suthar
  • 3,201
  • 1
  • 16
  • 28
  • possible duplicate of [Best way to run scheduled tasks](http://stackoverflow.com/questions/542804/best-way-to-run-scheduled-tasks) – CodeCaster May 26 '14 at 10:39
  • There are many posts explaining how to create a scheduler but I couldn't find one which uses datetime from the entity itself. – Lokesh Suthar May 26 '14 at 10:45
  • How would a third-party library understand your entities? You'll have to write some code to link your business logic to those libraries. – CodeCaster May 26 '14 at 10:46
  • They don't actually need to understand the entities but I am looking for a way schedule the jobs accordingly. Like If I could schedule a job when I create a new 'Appointment' and reschedule if I change the appointment time. – Lokesh Suthar May 26 '14 at 11:10
  • You can do that, but you'll have to write code to do so. – CodeCaster May 26 '14 at 11:13
  • Yes I understand that and I am trying to configure quartz.net but I find it's documentation a bit confusing. – Lokesh Suthar May 26 '14 at 11:14

1 Answers1

0

Have a look at Quarts.Net. this allows you to preform actions at selected times. I am not sure if you can be as granular as run this exact email at this exact time but you can get it to run a job every 5 mins (or faster) to check if any emails are scheduled to be sent and then send them.

I use the second approach and it works well for me where i run a job to update accounts and a different job to send out batch emails (if any are waiting) as a result of that.

KevDevMan
  • 808
  • 11
  • 23
  • I am actually trying to configure quartz according to my requirements but honestly I am finding it's documentation a bit difficult. Can you direct me towards an MVC 4 tutorial for quartz.net ? – Lokesh Suthar May 26 '14 at 11:13
  • this is a pretty good example http://stackoverflow.com/questions/3245975/quartz-net-setup-in-an-asp-net-website – KevDevMan May 26 '14 at 14:53