Object reference not set to an instance of an object.
System.NullReferenceException: Object reference not set to an instance of an object.
at System.Web.Helpers.WebMail.set_SmtpServer(String value)
I have tried to pass the WebMail type to it but that throws a compiler error about not allowing static types.
This class represents a helper, which is a component that simplifies web programming in ASP.NET Web Pages. You can use the WebMail class to send email messages from a web application.
I’m not sure how you have setup Hangfire, but in most cases, the execution of jobs will not happen in a ASP.NET Web Pages application. Typically, your web app will enque the job, and the job will be executed in a service, worker role, long-running console app or whatever.