Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trigger email on specific date

Tags:

c#

asp.net

I have C# web application that I want it to send out an email on a certain date, such as if equipment isn't returned on the day it was due. Data is in MS SQL database.

I've got all the email code already done, and I'm just curious how do I trigger this email, say after the COB on that particular day?

Thanks,

Eric

like image 592
Risho Avatar asked May 09 '26 23:05

Risho


2 Answers

Create a small console application that runs as a scheduled task.

It would do something like the following:

  1. Check the email database for unsent emails
  2. Check each unsent email for it's send date
  3. if the send date is equal to DateTime.Now then send the email
  4. Mark the email as sent
  5. Repeat foreach email
  6. Application exits an then runs again according to the scheduled task's settings

Updated

You mentioned you would like to do this with a trigger.. well I have never done that before, but have looked into it. I went with the console application approach. I liked this better. But here is a link on what I found on the trigger approach.

like image 81
Gabe Avatar answered May 12 '26 12:05

Gabe


You make an application that queries the database for all emails that should be sent out today and sends the emails. You then schedule that application to run each day with task scheduler.

like image 33
Klaus Byskov Pedersen Avatar answered May 12 '26 12:05

Klaus Byskov Pedersen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!