title: Creating ASP.NET MVC style views in a console application?
body: <p>I have a console application that requires me to send out e-mails. Right now I use a string builder to create the e-mails, but I'd like to get more fancy. Then it dawned on me: it would be nice to send my object to an ASP.NET MVC style view, where I'd have the HTML markup, and then return it to mail out. Right now, I have it going as;</p>
  
  <pre><code>    private void MailJobList(List&lt;Job&gt; newJobs) {
                  var body = new System.Text.StringBuilder();
                  var from = new MailAddress("daemon@mydomain.com");
                  var to = new MailAddress(addresslist.Get());
  
                  var message = new MailMessage(from, to);
  
                  message.Subject = "New job list";
  
      //mail settings ommitted here for brevity
  
                  body.Append("New jobs: ");
                  if (newJobs.Any()) {
                      foreach (var newJob in newJobs) {
                          body.Append(newJob.Job + ", ");
                      }
                  }
  
                  message.Body = body.ToString();
  
                  client.Send(message);
  }
  </code></pre>
  
  <p>Obviously that's just plain text, but I'd really like to be able to do something like:</p>
  
  <pre><code>var body = RenderHTMLMessage(newJobs);
  </code></pre>
  
  <p>It seems like I should be able to leverage ASP.NET MVC's view engine (or Spark or any other view engine) and not roll my own. If I'm off mark here or there's any easier way to do this, I'm open to suggestions.</p>