views:

35

answers:

3

Hello.

This is my first question so i will try and keep it consise and accurate, but go easy on me if you need to know anything extra.

Task: I have intended to write some code to send a newsletter to my members at a set time. (the early hours on a friday or saturday) The actual time does not need to be precise, but it needs to be roughly the same each week.

I have broken down the task into these main areas.

  1. Have something which checks the time/last run date etc.

  2. A function then runs. This will do a database interigation and get all the users who want to receive the newsletter

  3. Generate the email, and insert the usernames and email addresses into the mailmessage.

  4. send the mailmessage.

I have written all the code to do everything bar the timer/scheduler bit.

Basically i am having to login to the website when i need to send the mailout, and click a button.

All i am really asking is how do I automate the effect of clicking on the button.

I have read up lots on this but have had lots of contradicting views. Some say use a timer Others say timers are resource hungry and using a scheduler is better.

So far, the best 2 ways of doing the automated bit are as follows:

1) Have a timer on a windows service that then generates the emails. (i've built these in javascript before to do rolling images in a div, or to do a slideshow type thing.)

2) have scheduler call a web service at the specified time.

Basically, which is easier/more efficient/best?

The mailer will be sending ~15k+ emails, so it will be using MSMQ. I'd ideally like the users to receive the emails on a saturday or sunday morning.

I already have the c# code to generate the emails and send them.

Many thanks in advance for your help and input.

Del Greco.

A: 

Take a look at Quartz.Net.

Austin Salonen
A: 

Create a windows service - example here:

http://www.codeproject.com/KB/IP/smartmassemail.aspx

FiveTools
A: 

I agree with Austin on checking out Quartz.Net.

If that isn't an option for you, you can also run a simple scheduled job. This is pretty straightforward if you are on Windows (the Scheduled Tasks tool) and I assume the same for Linux. You have most of the hard work done already. Just make a C# program that sends out all the emails like you already have and have that program run by the scheduler at the appropriate time. It doesn't have to be difficult.

Boerema
Welcome to the site buddy!
Austin Salonen