当我使用Postal使用布局发送电子邮件时,邮件标题似乎没有被解析和包含在邮件消息中。
Views/Emails/_ViewStart.cshtml
@{ Layout = "~/Views/Emails/_EmailLayout.cshtml"; }Views/Emails/_EmailLayout.cshtml
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>ViewEmails</title>
</head>
<body>
<div>
@RenderBody()
</div>
</body>
</html>Views/Emails/ResetPassword.cshtml
To: @ViewBag.To
From: @ViewBag.From
Subject: Reset Password
Views: HtmlViews/Emails/ResetPassword.html.cshtml
Content-Type: text/html; charset=utf-8
Here is your link, etc ...当我收到邮件时,正文中包含了所有到、来自、主题和视图的标题。
有人知道怎么做正确吗?
更新了(感谢安德鲁),这是工作的:
Views/Emails/_EmailLayout.cshtml
@RenderSection("Headers", false)
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>ViewEmails</title>
</head>
<body>
<div>
@RenderBody()
</div>
</body>
</html>Views/Emails/ResetPassword.cshtml
@section Headers {
To: @ViewBag.To
From: @ViewBag.From
Subject: Reset Password
Views: Html
}Views/Emails/ResetPassword.html.cshtml
@section Headers {
Content-Type: text/html; charset=utf-8
}
Here is your link, etc ...发布于 2014-04-23 08:32:13
一种选择是使用Razor部分。
在布局顶部添加:
@RenderSection("Headers")然后在视图中添加:
@section Headers {
To: @ViewBag.To
From: @ViewBag.From
Subject: Reset Password
Views: Html
}发布于 2014-04-21 10:01:45
移动第一行
内容-类型: text/html;charset=utf-8
从视图/电子邮件/ResetPassword.html.cshtml到视图/EmailLayout.cshtml
Content-Type: text/html; charset=utf-8
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>ViewEmails</title>
</head>
<body>
<div>
@RenderBody()
</div>
</body>
</html>https://stackoverflow.com/questions/23154829
复制相似问题