0
我正在使用RazorEngine生成帶模板的電子郵件。使用RazorEngine電子郵件模板在身體中生成html
我遇到的問題是我無法在電子郵件正文中添加換行符。
var model = new EmailModel
{
Destination = "[email protected]",
Subject = "Some Subject",
Body = "Hello <br> Break <br> it <br> up"
};
var service = TemplateManager.RazorService;
var htmlBody = service.RunCompile("EmailTemplate.cshtml", model.GetType(), model);
await EmailService.SendEmail(model.Destination, model.Subject, htmlBody);
我試着做我的模板如下:
@Html.Raw(Model.Body)
但它仍然不會解碼HTML,任何想法?
什麼樣的通過''htmlBody'方法RunCompile'返回的HTML字符串?同時顯示您的'EmailTemplate.cshtml'內容代碼。 –