I just started using hangfire to send an email when new members register on my site. I have set it up correct according to tutorials on hangfire documents and I tested to see that hangfire works by enqueuing a simple console.writeline. But when i try to fire the email-method, i get this type of error.
System.InvalidOperationException: variable 'j' of type 'xxx.yyy.Jobs.SendEmailJob' referenced from scope '', but it is not defined
The code looks like this:
public class BackgroundEmailOfferService : IEmailOfferService2 { public Task SendAMail(MailData data) { BackgroundJob.Enqueue<SendEmailJob>(j => j.SendEmail(data).WaitAndUnwrapException()); return Task.CompletedTask; } }
The maildata-object is just string values with name, facebookId and so on.
I appreciate any help I can get to solve this issue! thanks!