title: Razor View Page as Email Template
body: <p>I have designed an Email Template from Razor Syntax.  When I send this template as Email using C# code and SMTP protocol, I get bare Razor and HTML markups as Email Body.  Am I wrong in this approach?  Are Razor Pages allowed as Email Template? </p>
  
  <p>Here is my Page</p>
  
  <pre><code>@inherits ViewPage
  @{
  Layout = "_Layout";
  ViewBag.Title = "";
  }
  &lt;div class="container w-420 p-15 bg-white mt-40"&gt;
  &lt;div style="border-top:3px solid #22BCE5"&gt;&amp;nbsp;&lt;/div&gt;
  &lt;span style="font-family:Arial;font-size:10pt"&gt;
      Hello &lt;b&gt;{UserName}&lt;/b&gt;,&lt;br /&gt;&lt;br /&gt;
      Thanks for Registering to XYZ Portal&lt;br /&gt;&lt;br /&gt;
      &lt;a style="color:#22BCE5" href="{Url}"&gt;Click to Confirm Email&lt;/a&gt;&lt;br /&gt;
  
      &lt;br /&gt;&lt;br /&gt;
      Thanks&lt;br /&gt;
      Admin (XYZ)
  &lt;/span&gt;
  </code></pre>
  
  <p></p>
  
  <p>Update..</p>
  
  <pre><code> using (StreamReader reader = new StreamReader(HttpContext.Current.Server.MapPath("~/ContentPages/EmailConfTemplate.cshtml")))
    {
       body = reader.ReadToEnd();
       //Replace UserName and Other variables available in body Stream
       body = body.Replace("{UserName}", FirstName);
  
    }
  </code></pre>
  
  <p>Later On I am replacing the SMTP Code as ..</p>
  
  <pre><code>  MailMessage message = new MailMessage(
      ApplicationWideData.fromEmailId, // From field
      ToEmailId, // Recipient field
      "Click On HyperLink To Verify Email Id", // Subject of the email message
      body
     );
  </code></pre>