Scheduled email distribution

T

Thomas I.

I would like to schedule at regular intervals an automated e-mail report
from a web server. I have the logic written to send the e-mail in C#.

However, is there a way I can schedule it? How could I trigger the code to
send?

Thanks!
 
B

Brock Allen

You can use the windows scheduler to do this from the operating system. Or
to do it programitically, you could use a Timer:

// start now and fire every 60 seconds
Timer MyTimer = new Timer(new TimerCallback(Callback), null, 0, 1000 * 60);

static void Callback(object o)
{
// send emails
}

Note, you must keep the reference to the Timer alive, otherwise it gets GC'd
and won't fire anymore. So, make MyTimer a static variable.
 
J

John Timney \(ASP.NET MVP\)

Create a small windows service that calls a web service method.

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director
 
J

JiangZemin

Hi, just wondering, are Windows Services generally preferred over a console
app setup within Task Scheduler? I would have thought for something that
happens at regular intervals, itd be easier to do it the latter way, but
maybe i just have sentimental feelings for Task Scheduler.

-Premier JiangZemin
 
B

Brock Allen

I'd suggest the OS's task scheduler, as it's alrewady written, rather than
you having to work out some of those details.
 
T

Tampa.NET Koder

I was thinking about doing the same kinda thing only with a events
notifications senario where events were stored in a DB with date and times
and basically I wanted to have this queried every 1hr or so to remind me of
these events. I was thinking a Windows Service however now that you bring
it up, task scheduler may be a better fit since the timer portion is already
implemented. However, once I grab the date and times of the event reminders
is it best to use Web Services or .NET Remoting to marshal this data across
to my client app? Because we are crossing application boundaries so I would
assume that we have to use one of these methods. Any input would be
appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top