So i have a job for sending bulk emails.
And they have to be sent at a time in the future. Which made me choose hangfire as the best option for this task.
The problem i am having is:
If i pass the method that sends the email to hangfire, the email doesn’t get sent.
But if i call the method just above the hangfire code (to rule out any issues with that method) the emails are sent but the hangfire job doesn’t send these emails.
I can see the Hangfire job moving from scheduled, to succeeded but the emails don’t get sent.
Is there something i am failing to understand when it comes to background jobs and email sending?
Please add the source code you use for the following sentenses.
You can add highlighted source code by embracing it with so-called code fences:
```csharp
<source code>
```
Thank you for your reply:
// Create Email job
HangfireCampaignMailManager hfcm = new HangfireCampaignMailManager();
clscampaigns_email campemail = new clscampaigns_email();
campemail.LoadByCampaign(cam.id); // campaign data
// Create Send Email Scheduled Job
hfcm.sendmail(cam.id); // the method that sends the email without hangfire
campemail.jobid = BackgroundJob.Schedule(() => hfcm.sendmail(cam.id), hfcm.exactDate(campemail.deploymentdate));
campemail.Save();
@emmanuel, what hfcm.sendmail
looks like? Can you show it to me?
Hi Odinserj,
Sorry i had to rush off to other commitments but i finally found a solution to the problem,
Inside - hfcm.sendmail there was a line calling a method which had the following line:
System.Web.HttpContext.Current.Server.MapPath(Filename);
Which caused an exception when the job fired and i replaced it with
System.Web.Hosting.HostingEnvironment.MapPath(Filename);
And everything has been working fine since,
Thank you very much for your help.