title: Receiving "Value cannot be null. Parameter name: httpContext" when sending MVC Mailer email from ASP MVC
body: <p>My MVC Mailer instance is failing when I send from the server. I'm getting the error <code>Value cannot be null.Parameter name: httpContext</code> when I attempt to send an email.</p>
  
  <p>my code looks like this:</p>
  
  <pre><code>    public static void SendApproval(TimeOffRequest request)
      {
          MailService mailer = new MailService();
          mailer.ViewData.Model = request;
  
          MvcMailMessage mailMessage = new MvcMailMessage
          {
              Subject = $"PTO request approved for {request.StartTime} to {request.EndTime}",
              From = new MailAddress("calendar@company.com"),
          };
          mailMessage.To.Add(new MailAddress(request.Requester.Email));
  
          if (mailMessage.To.Count == 0)
              return;
  
          mailer.PopulateBody(mailMessage, "RequestApproved");
          mailMessage.Send();
      }
  </code></pre>
  
  <p>It's specifically failing on the line <code>mailer.PopulateBody(mailMessage, "RequestApproved");</code></p>
  
  <p>It is being called from the post of a controller endpoint. Why is the context missing in this scenario? I attempted to manually pass the context and that failed as well.</p>
  
  <p>Heres the top of the stack trace:</p>
  
  <pre><code>System.Web.Routing.RouteCollection.GetRouteData(HttpContextBase httpContext) +505
     Mvc.Mailer.MailerBase.CreateControllerContext() +98
     Mvc.Mailer.MailerBase.ViewExists(String viewName, String masterName) +127
  </code></pre>