我在将强类型模型传递给 MvcMailer 视图时遇到了麻烦。我正在使用 asp.net mvc3 并使用 nuget 安装了 MvcMailer3。
没有错误消息并且消息已成功发送,但未填充数据字段。我正在做所有事情,也尝试使用 ViewBag 字段,但同样的问题 - 消息发送成功但字段未填充......
请帮助...我被困了两天!
这是我的控制器和查看代码....
//控制器代码
public ActionResult Index()
{
string invoicenumber = "BC-00000002";
IEnumerable<Quantum.Models.usp_MasterPrintInvoice_Result> mpi = db.usp_MasterPrintInvoice(invoicenumber);
IEnumerable<PrintDetailObject> printdetailobj = from anmpi in mpi select new PrintDetailObject { Head = anmpi.Head, ContributorName = anmpi.Name, RegistrationNumber = anmpi.RegistrationNumber, InvoiceNumber = anmpi.InvoiceNumber, InvoiceDate = anmpi.Date, Amount = anmpi.Amount, PaymentMonth = anmpi.Month, ReceivedBy = anmpi.Operator };
ViewData.Model = printdetailobj.FirstOrDefault();
IUserMailer mailer = new UserMailer();
mailer.Welcome().Send();
return View();
}
查看代码
@model Quantum.Models.PrintDetailObject
@using Mvc.Mailer
<h2>Invoice</h2>
<fieldset>
<div class="print-details-page">
<legend>@Html.DisplayFor(model => model.Head)</legend>
<div class="display-label">InvoiceNumber</div>
<div class="display-field">
@Html.DisplayFor(model => model.InvoiceNumber)
</div>
<div class="clear"></div>
<div class="display-label">Date</div>
<div class="display-field">
@Html.DisplayFor(model => model.InvoiceDate)
</div>
<div class="clear"></div>
<div class="display-label">Recieved From:</div>
<div class="display-field">
@Html.DisplayFor(model => model.ContributorName)
</div>
<div class="clear"></div>
<div class="display-label">Registration Number:</div>
<div class="display-field">
@Html.DisplayFor(model => model.RegistrationNumber)
</div>
<div class="clear"></div>
<div class="display-label">Amount:</div>
<div class="display-field">
@Html.DisplayFor(model => model.Amount)
</div>
<div class="clear"></div>
<div class="display-label">Amount in Text:</div>
<div class="display-field">
@Html.DisplayFor(model => model.AmountText)
</div>
<div class="clear"></div>
<div class="display-label">Month:</div>
<div class="display-field">
@Html.DisplayFor(model => model.PaymentMonth)
</div>
<div class="clear"></div>
<div class="display-label">Recieved By:</div>
<div class="display-field">
@Html.DisplayFor(model => model.ReceivedBy)
</div>
<div class="clear"></div>
<br />
<p>Received with many thanks.</p>
</div>
</fieldset>
我只收到以下文本作为电子邮件正文:
Invoice
InvoiceNumber
Date
Recieved From:
Registration Number:
Amount:
Amount in Text:
Month:
Recieved By:
Received with many thanks.