im not using an event scheduler just asp.net mvc and need to send a reminder 4 days before event. I have the Date Stored of Event(Event_Start), can u please help?
I have created a class in the controller public void Reminder() , but now im stuck
im not using an event scheduler just asp.net mvc and need to send a reminder 4 days before event. I have the Date Stored of Event(Event_Start), can u please help?
I have created a class in the controller public void Reminder() , but now im stuck
It is probably best for you to use the Scheduler service to call/visit the "Reminder" page at the determined time. eg http://mysite/Reminder/SendEmails/EventId. You can handle the email-send from within your controller.
Your Reminder() method would do the work of sending the emails for those events that are 4 days off according to the items you retrieve from the database. You can use the System.Net.Mail.SmtpClient class to do the actual sending of the emails.
The bigger challenge is how to trigger the path to execute once per day. Other worries is that the actual sending can take a while and may time out if you don't take care of the allowed request time in the web.config.
For those type of activities it can be easier to just create a console app and have it trigger via a daily Windows Scheduled Task on the server.
Here's a previous discussion on the question of doing it on MVC: Send Email in Background.
You could potentially create a page that determines what needs to be sent and sends using System.Net.Mail. Then create a simple batch file that hits that page regularly (the schedule can be handled through Windows Scheduled Jobs).
If you're dead set against creating something that can either run as a service or run as a scheduled job, then the other option is to use the cache expiration as a job scheduler. People have been doing this with ASP.NET for a while. The article is old, but it should still work okay:
you can use http://quartznet.sourceforge.net/ for trigger event check function. it's very easy and no need to Windows Scheduled Task for this job.