我正在尝试在后台作业中使用 ASP MVC Postal 发送电子邮件,如下所示:
public void CommentCreated(Comment comment, ApplicationUser user)
{
var viewsPath = Path.GetFullPath(HostingEnvironment.MapPath(@"~/Views/Emails"));
var engines = new ViewEngineCollection();
engines.Add(new FileSystemRazorViewEngine(viewsPath));
var emailService = new Postal.EmailService(engines);
var email = new CommentCreatedEmail
{
To = user.Email,
From = ConfigurationManager.AppSettings["SmtpEMailFrom"],
Subject = "Comment Created"
Comment = comment,
User = user
};
emailService.Send(email);
}
我的观点 CommentCreated.cshtml 如下:
@model MyApp.Models.CommentCreatedEmail
To: @Model.To
From: @Model.From
Subject: @Model.Subject
<p>
<a href="@Url.Action("Details", "Comment", new { id = @Model.Comment.Id }, "http")">@Url.Action("Details", "Comment", new { id = @Model.Comment.Id }, "http")</a>
但我收到以下错误:
Exception thrown: 'RazorEngine.Templating.TemplateCompilationException' in RazorEngine.dll
Exception thrown: 'System.Web.HttpCompileException' in System.Web.dll
有任何想法吗