3 ms·
In related news, if you're using ASP.NET MVC, there is a way to use the familiar Razor templating engine to template your emails (or anything else, really). To
by DenisM 13y ago
In related news, if you're using ASP.NET MVC, there is a way to use the familiar Razor templating engine to template your emails (or anything else, really). To do that you just need to install RazorEngine ( http://razorengine.codeplex.com/ http://razorengine.codeplex.com/ ) - it exposes Razor in a way that it can be used for things other than rendering pages.
Here's how I use it right now:
string templateFile = HttpContext.Current.Server
.MapPath("~/App_Data/InviteUser.cshtml");
string template = System.IO.File.ReadAllText(templateFile);
var model = new
{
inviterName = "A user",
inviterEmail = inviterEmail,
manufacturerName = inviterMfr,
UserId = person.PrimaryEmail,
UserPassword = person.GeneratedPassword,
};
var bodyHtml = RazorEngine.Razor.Parse(template, model);
And the template:
<html>
<body>
<p>
@Model.inviterName (@Model.inviterEmail)
@if (Model.manufacturerName != null)
{
<span>on behalf of <b>@Model.manufacturerName</b></span>
}
is inviting you to explore Mercury Catalog by AmpTab - the best furniture catalog app for the iPad:
</p>
[SNIP-SNIP]
- mrmch 13y agoThat's pretty cool Denis. We don't have an official .Net client yet, but we do have some solid code samples for our REST API. In our experience email templates are a little different from regular HTML templates; things like built-in css inlining, A/B testing, and giving access to non-technical folks.
- DenisM 13y agoI see. The linked page pigeonholes you as a competitor to Razor (or other similar templating libraries) - none of the other benefits are even mentioned there. I think it's going to be a problem for you - people jump to conclusions based on what they see.
- mrmch 13y agoYou're correct Denis, our developer page purely speaks to the "get templates out of source code" value prop -- maybe a mistake, but it was something we were testing today :)