14578446
14578446

Reputation: 1074

execute scheduled task in C#

I have a requirment to build a small utility, which fires a sql query to fetch a list of user email addresses and send emails to them scheduled to be executed daily.

I was wondering what may be a good way to perform this in .net

I am working on VS2010 premium, c# 4.0

Upvotes: 2

Views: 5493

Answers (7)

user172163
user172163

Reputation:

If you want to do this emailing procedure in web environment(ASP.Net), you can use ATrigger scheduling service. A .Net library is also available to create scheduled tasks without overhead.

Disclaimer: I'm among their team.

Upvotes: 0

James Hill
James Hill

Reputation: 61872

.Net would be just fine for this. I suggest writing a console application to do what you require, and using Windows Task Scheduler to run your application at your chosen interval.

Upvotes: 1

Core_F
Core_F

Reputation: 3442

Do you need to write it in .net?

If yes, then go for the task scheduler like already suggested. If not, then you could also create a job in the database directly.

Upvotes: 1

parapura rajkumar
parapura rajkumar

Reputation: 24413

Here is a nice example to write scheduled tasks in .NET

Upvotes: 2

Isak Savo
Isak Savo

Reputation: 35934

Write the application in whatever language or platform you want and then use the Windows Task Scheduler to make the application run according to your schedule.

That way, you can focus your application on its core thing (fetching stuff, sending emails) and let Microsoft worry about the details of creating a robust scheduling service.

Upvotes: 2

DanTheMan
DanTheMan

Reputation: 3277

You should use the task scheduler, and have it execute your program once a day.

An alternative may be to write a service that waits until a certain time in a day and runs this simple task, but this seems a little too heavy-handed unless you have more plans for this service in the future. (So, for example, you want the service to be able to send emails, do some database maintenance, listen on some port, etc.)

Having a application run full-time in the background for such a simple task doesn't seem like a good way to go about it. There are too many ways to stop an application.

Upvotes: 2

Massimiliano Peluso
Massimiliano Peluso

Reputation: 26737

It depends by your requirements.

I think you could create a console application that encapsulate this behavior then you can schedule the task using windows schedule task

Upvotes: 2

Related Questions