首页 > 解决方案 > 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#asp.net-mvcasp.net-mvc-4actionmailer

解决方案


推荐阅读