pun*_*ret 12 asp.net-mvc postal
似乎当我使用Postal使用Layout发送电子邮件时,标题未被解析并包含在邮件消息中.
查看/电子邮件/ _ViewStart.cshtml
@{ Layout = "~/Views/Emails/_EmailLayout.cshtml"; }
Run Code Online (Sandbox Code Playgroud)
查看/电子邮件/ _EmailLayout.cshtml
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>ViewEmails</title>
</head>
<body>
<div>
@RenderBody()
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
查看/电子邮件/ ResetPassword.cshtml
To: @ViewBag.To
From: @ViewBag.From
Subject: Reset Password
Views: Html
Run Code Online (Sandbox Code Playgroud)
查看/电子邮件/ ResetPassword.html.cshtml
Content-Type: text/html; charset=utf-8
Here is your link, etc ...
Run Code Online (Sandbox Code Playgroud)
当我收到邮件时,所有标题To,From,Subject和Views都包含在正文中.
有谁知道如何正确地做到这一点?
更新(感谢安德鲁),这工作:
查看/电子邮件/ _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>
Run Code Online (Sandbox Code Playgroud)
查看/电子邮件/ ResetPassword.cshtml
@section Headers {
To: @ViewBag.To
From: @ViewBag.From
Subject: Reset Password
Views: Html
}
Run Code Online (Sandbox Code Playgroud)
查看/电子邮件/ ResetPassword.html.cshtml
@section Headers {
Content-Type: text/html; charset=utf-8
}
Here is your link, etc ...
Run Code Online (Sandbox Code Playgroud)
And*_*vey 16
一种选择是使用Razor部分.
在布局的顶部添加:
@RenderSection("Headers")
Run Code Online (Sandbox Code Playgroud)
然后在视图中添加:
@section Headers {
To: @ViewBag.To
From: @ViewBag.From
Subject: Reset Password
Views: Html
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3612 次 |
最近记录: |