title: Use Razor views as email templates inside a Web Forms app
body: <p>I have an asp.net Web Forms application that needs to send emails.  I like the Razor syntax and as you can use Razor outside of MVC I thought I'd try and use that.  I've seen that you can programmatically pass a template string to razor but I'd like to keep my razor templates as separate .cshtml files.</p>
  
  <p>Does anyone have any simple, idiot-proof advice as to how to do this?  I've tried to load them from file like this:</p>
  
  <pre><code>UserDetails userDetails = new UserDetails {Name = "Fred"};
  string template = File.OpenText("Email/UserDetailsEmail.cshtml").ReadToEnd();            
  string messageText = Razor.Parse(template, userDetails);
  </code></pre>
  
  <p>All to no avail.  There's an exception finding the file.  I'm using the razorengine dll.</p>
  
  <p>I have everything else working, the smtp server etc, just not the views.</p>
  
  <p>Any help appreciated.</p>