Am using Gmail API to send emails. I would like to send the email every minute (this is for testing, will set a proper interval later). Now, I have a working hangfire setup and also a working gmail api setup. both are tested. but when I put them together as follows, I don’t see any email, though the Hangfire job runs.
RecurringJob.AddOrUpdate(() => job.SendEmail(service), Cron.Minutely);
When I debug through, I don’t even get it doesn’t even hit my SendEmail method.
Any thoughts on what am doing wrong?
Edit: This is not only a problem with email sending job, pretty much any other job. Eg: I have a test method, all it does is print to console a test message. I associate it to the recurring job like below and still nothing is shown in console.
using (var server = new BackgroundJobServer()) { Console.WriteLine("Hangfire Server started. Press any key to exit..."); RecurringJob.AddOrUpdate<RecurringEmail>(x => x.TestMethod(), Cron.Minutely); Console.ReadKey(); }
public void TestMethod()
{
Console.WriteLine("Called from hangfire!!!");
}
I can see it print the message “Hangfire Server started. Press any key to exit…” but the TestMethod() doesn’t get called.