バックグラウンド ジョブで 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
何か案は