Razor 视图作为电子邮件模板 [英] Razor views as email templates
本文介绍了Razor 视图作为电子邮件模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在 mvc3 中创建电子邮件引擎,并尝试使用 razor 视图作为电子邮件模板.我听说这是可能的,但我还没有找到任何关于它的信息.
I am creating an email engine in mvc3 and I am trying to use razor views as email templates. I heard this is possible but I have not yet found any information about it.
推荐答案
您可以使用http://razorengine.codeplex.com/ 实现这一目标.它允许你在 mvc 之外使用 razor.
You can use http://razorengine.codeplex.com/ to achieve this. It allows you to use razor outside of mvc.
string Email = "Hello @Model.Name! Welcome to Razor!";
string EmailBody = Razor.Parse(Email, new { Name = "World" });
实施起来很简单,可在 http://nuget.codeplex.com/ 上找到,以便轻松集成到您的项目中.
It's simple to implement and it's available on http://nuget.codeplex.com/ for easy integration into your projects.
这篇关于Razor 视图作为电子邮件模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文