Вопрос

Code below in Global.asax works fine with IIS but when I deploy the application to Azure it doesn't work.

   protected void Application_Start(object sender, EventArgs e)
   {
        System.Timers.Timer timer = new System.Timers.Timer();
        timer.Interval = 60000;       
        timer.AutoReset = true;
        timer.Elapsed += new ElapsedEventHandler(NewCandidates);
        timer.Enabled = true; 
    }

    public void NewCandidates(object source, System.Timers.ElapsedEventArgs e)
    {
        SendEmail.MailSender mail = new MailSender();
        mail.EmailSender();
    }

All because Azure does not support email trigger. I created the Web Application above to send smtp email and published to Azure as cloud service. Every Friday an email supposed to be sent having this week's records from the Candidates table. Anything to schedule an email would help, but I think I cannot go for SendGrid.

Это было полезно?

Решение

You should consider moving your code out to leverage Azure Scheduler (http://www.windowsazure.com/en-us/services/scheduler/). This will be a more reliable scheduling service than using the above approach.

Reliable mail delivery will really only be via use of SendGrid - anything else is likely to get bounced by one blacklist or another. You can send up to 25,000 emails a month with SendGrid for free (http://sendgrid.com/windowsazure.html).

If you can't use SendGrid then you could use an SMTP relay outside of Azure (say, on your own network) that you can bounce mail through though even that may not work unless you modify the messages to remove the origin IP / hostname.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top