Create email using ASP.NET MVC views
Postal provides an HTML helper extension method to allow embedding images into an email, instead of linking to an external image URL.
First, make sure your Web.config
razor configuration contains the Postal namespace.
This makes the helper available in your email views.
<configuration>
<system.web.webPages.razor>
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="Postal" />
</namespaces>
</pages>
</system.web.webPages.razor>
</configuration>
The EmbedImage
method will embed the given image into the email and generate an <img/>
tag to reference it.
To: john@example.org From: app@example.org Subject: Image @Html.EmbedImage("~/content/postal.jpg")
Postal will try to resolve the image’s filename, relative to the web application’s root directory.