Using Quartz for sending emails

11 views
Skip to first unread message

mattcole

unread,
Dec 22, 2009, 11:58:55 AM12/22/09
to Quartz.NET
Hi,

I think this will demonstrate my very novice level of understanding of
Quartz .Net, but I'm wondering if I can use the inbuilt send email job
to send emails for my application.

That obviously shouldn't be a problem, I think the problem revolves
around my lack of understanding of jobs and triggers. I have a custom
job that is set up to run each day and it checks a db table for some
information and if any is found it needs to send some emails. I was
hoping I might be able to schedule or trigger a SendMailJob from
inside my job.

What's the best way to go about doing this? I really just want to
create a job that is triggered instantly then disappears. Is this a
bit of a misuse of Quartz? I've written code along the lines of:

var job = new JobDetail("emailJob", "global", typeof (SendMailJob));
job.Durable = false;
// put some stuff in jobdatamap

scheduler.ScheduleJob(job,
TriggerUtils.MakeImmediateTrigger
("sendEmail", 0, new TimeSpan(0)));

This throws an error telling me that "Unable to store Job with name:
'emailJob' and group: 'global', because one already exists with this
identification". I assume as I haven't created a job with that name
and group in my quartz_jobs.xml file this means that the job created
the last time this code ran is still in the scheduler.

I tried to instead define a generic job in the quartz_jobs.xml file,
and then trigger it, but it seems to try and create an instance of the
job despite the absence of a trigger and then throws an exception as
I'm not providing it with its required configuration (email message,
sender etc).

I get the feeling I'm going around this the wrong way entirely, does
anyone have any ideas of how best to do something like this?

Thanks,
Matt

Reply all
Reply to author
Forward
0 new messages