-
Notifications
You must be signed in to change notification settings - Fork 168
Multiple Alternative Views
MrGeneric edited this page May 17, 2013
·
4 revisions
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: [email protected]
From: [email protected]
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>