c# - MVC c#.net ActionMailer.Net.Mvc.EmailResult 中的电子邮件 html 正文在哪里?
问题描述
我们正在使用 .html.cshtml 电子邮件模板将电子邮件正文生成到 EmailResult 对象中:
public EmailResult GetEmail()
{
. . .
return Email(emailTemplate, model);
// this goes first to emailTemplate.html.cshtml
// inside emailTemplate.html.cshtml last statement is
// <div>
// @if (emailContent != "")
// {
// <text>@Html.Raw(emailContent)</text>
// }
//
// Then it goes to _email_layout.cshtml
// where there is: @RenderBody()
//
// only Then it returns as EmailResult
// So, it seems EmailResult Should have email body somewhere ??
}
然后我们需要提取创建的电子邮件文本以分配给另一个变量:
EmailResult emr = GetEmail();
. . .
var htmlContent = emr.Mail.Body; // Body is null here, why ???
ActionMailer.Net.Mvc.EmailResult 中的电子邮件 html 正文在哪里?非常感谢
解决方案
推荐阅读
- c# - C#根据Attribute做一个简单的拦截
- c# - 我不明白为什么在基类中测试可能的接口是错误的
- c# - 安装 Microsoft.Azure.SignalR.AspNet 会在部署到服务器时导致方法未实现运行时错误,但在 Visual Studio 2017 上运行良好
- reactjs - Redux 改变多种状态
- java - ListView 适配器异步操作
- python-3.x - 如何在 NEAT(增强拓扑的神经进化)中设置层数?
- ionic4 - Ionic 4 构建后未在平台中创建“ios”文件夹
- fortran - 在 Fortran 中编写混合的 ascii 和二进制数据
- events - 如何在 Modelica 中使用布尔开关来防止库存低于零?
- hanami - 如何使用 Hanami::Repository 在更新/删除命令中使用条件?