Reputation: 4733
I'm trying to send email automatically on 00:00; I've used Quartz.net but there's problem about medium trusted environment (It's shared hosting). I've read this on stackoverflow but didn't get any idea how to do that.
Another I can't create windows service as it's shared hosting.
Is there any other way to do that?
Upvotes: 0
Views: 1823
Reputation: 141690
It's not a very good practise, but you can do something like that(for example i'm using MVC 4):
In Global.asax you can try to do next:
public class Global : HttpApplication
{
void Application_Start(object sender, EventArgs e)
{
...//your current code
SendEmail();
SetUpTimer();
}
private static System.Threading.Timer _timer;
private void SetUpTimer()
{
TimeSpan timeToGo = DateTime.Now.AddDays(1).Date - DateTime.Now; //timespan for 00:00 tommorrow
_timer = new System.Threading.Timer(x => SendEmail(), null, timeToGo, new TimeSpan(1,0,0,0));
}
public void SendEmail()
{
//check if email was sent today if not send one
}
}
Upvotes: 1