title: Email Sender Library with Razor (.cshtml) Templates. .net core 2.0
body: <p>I have been searching for this ages for a clear solution for sending emails with email templates from embedded source files and still I haven't found a clear answer to this.</p>
  
  <p>Razor views are really nice to use as a template for emails.</p>
  
  <p>I am trying to to create a class library as a package that will contain views(cshtml files) and models for each view. That class library will also have a service as EmailSender.</p>
  
  <p>Then that class library will be referenced in a web application to send emails. The library obviously be re-usable in other projects.</p>
  
  <p>EmailSender service will have methods for each email types. The web application will pass the model and class library will prepare the email content (parse the model into view) and return the string content. That string content will be sent as htmlbody email.</p>
  
  <p>I have looked at this RazorLight <a href="https://github.com/toddams/RazorLight" rel="noreferrer">library</a>. This doesnt seem to be completed or updated for core 2.0 yet.</p>
  
  <p>Another solution I came cross is <a href="https://www.c-sharpcorner.com/article/send-email-using-templates-in-asp-net-core-applications/" rel="noreferrer">here</a>. The issue with this approach is that email templates do not contain model properties. Basically, templates contain {0}, {1} etc and format is used to parse the model data into template. If there are a lot of parameters in the template it would be hard to remember which parameter is which.</p>
  
  <p>I just recently seen this article <a href="https://blogs.msdn.microsoft.com/webdev/2018/03/01/asp-net-core-2-1-razor-ui-in-class-libraries/" rel="noreferrer">ASP.NET Core 2.1.0-preview1: Razor UI in class libraries</a></p>
  
  <p>It tells that Core 2.1.0 will enable to add views in class libraries. Would this be the solution? </p>
  
  <p>Or do you have any better idea to achieve this?</p>