Create email using ASP.NET MVC views
You want to send an email that includes both rich HTML and plain text versions? Postal makes it easy.
Create the main view. This will have the headers and reference the views to use.
~\Views\Emails\Example.cshtml
To: test@test.com From: example@test.com Subject: Fancy email Views: Text, Html
Create the text view. Note the naming convention: Example.cshtml
→ Example.Text.cshtml
Views\Emails\Example.Text.cshtml
Content-Type: text/plain; charset=utf-8 Hello @ViewBag.PersonName, This is a message
You must specify a single Content-Type header.
Create the HTML view, also with a single Content-Type header.
Views\Email\Example.Html.cshtml
Content-Type: text/html; charset=utf-8
<html>
<body>
<p>Hello @ViewBag.PersonName,</p>
<p>This is a message</p>
</body>
</html>