0

I have a webAPI project with reminder class

There it is

public class ReminderItem
{
    public Guid Id { get; set; }

    public string Subject { get; set; }

    public string Notes { get; set; }

    public DateTime RemindDate { get; set; }

    public Guid AuthorId { get; set; }

    public string AuthorEmail { get; set; }

    public bool IsActive { get; set; }

    public bool IsCancelled { get; set; }

}

I need to make add/update/delete events for it. This is all done already and works. But also I need to make email message sending to AuthorEmail on DateTime. This is RemindDate property. But I never do this. Maybe you can help me, how I can do this? Or where I can read about this? Because I understood how to do this on program launch. Like, check DateTime now with DateTime in DB. But, how I can do this to make it automatically when the program is already running?

Udara Abeythilake
  • 1,167
  • 1
  • 19
  • 30
Eugene Sukh
  • 1,997
  • 4
  • 25
  • 64

2 Answers2

1

You could have a scheduled task run in the background and check if you need to send some emails. See here for a description in dotnetcore: https://thinkrethink.net/2018/08/02/hostbuilder-ihost-ihostedserice-console-application/

Rob Bos
  • 866
  • 1
  • 8
  • 21
0

sounds like you have some deferred work! I'd recommend utilizing a email sending service like sendgrid. they have a schedule email api where you can send the details in, and they will wait until the date and time is met before sending (https://sendgrid.com/docs/API_Reference/SMTP_API/scheduling_parameters.html)

If you are wanting your own solution using SMTP, it'll be more involved, since you will need to use a storage mechanism like azure service bus queue's and a web job to host the work that is scheduled.

Nathan Tregillus
  • 5,638
  • 2
  • 48
  • 81