user3071613
user3071613

Reputation: 23

How to add email scheduler in asp.net?

I want to configure e-mail scheduler in an Asp.net web application and I don't know how to achieve this thing. Does anybody have any idea how I can achieve this? I just want to send emails at specific time.

Upvotes: 0

Views: 143

Answers (3)

Dmitry Sikorsky
Dmitry Sikorsky

Reputation: 1501

I use next solution.

In your Global.asax add this line to Application_Start method:

this.Application["Timer"] = new Timer(new TimerCallback(EMailProcessor.Process), null, 0, 60000);

Your EMailProcessor class may look like:

public class EMailProcessor
{
    public static void Process(object state)
    {
        // Your code here
    }
}

Hope this is what you need.

UPD: This works because the asp.net application are 'real' applications and running even there are no requests to the server.

Upvotes: 0

bjorsig
bjorsig

Reputation: 1107

I think the easiest way would be to write a good old fashioned console program which sends the emails when it runs. Then you simply use a scheduler to run it on the time(s) you want.

Upvotes: 1

TheTechGuy
TheTechGuy

Reputation: 17354

You can use scheduler frameworks such as Quartz.net. You can create Jobs in Quartz.net and creates triggers. Triggers kicks in the job at particular time, day, month, nightly basis etc etc. You will be using Cron scheduler to schedule your jobs (that is triggers).

Upvotes: 1

Related Questions