0

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

Alss
  • 23
  • 1
  • 6

4 Answers4

0

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.

JcMaltaDev
  • 1,344
  • 1
  • 9
  • 17
0

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.

Community
  • 1
  • 1
Turnkey
  • 9,266
  • 3
  • 27
  • 36
  • I Have Created An Email Class using the System.Net.Mail – Alss Aug 15 '11 at 03:49
  • Good to make that a separate service class. That way it will still be reusable if you decide to go to an alternate implementation such as a console app. – Turnkey Aug 15 '11 at 12:45
  • My problem now is actual having a form to input email details from database to send it like , any ideas please? – Alss Aug 15 '11 at 23:54
  • I don't quite understand the question. If you mean having a form for the users to input their emails I would do some sort of "Subscriptions" or "Profile" controller in which they can input the details that way. – Turnkey Aug 20 '11 at 12:33
0

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:

http://www.codeproject.com/KB/aspnet/ASPNETService.aspx

OneCleverMonkey
  • 422
  • 4
  • 15
0

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.

Eray Aydogdu
  • 240
  • 1
  • 4
  • 16