Asp.net MVC邮件程序将模型传递到邮件视图
我正在使用MVC邮件器-我的控制器中有:Asp.net MVC邮件程序将模型传递到邮件视图,asp.net,asp.net-mvc,asp.net-mvc-3,mvcmailer,Asp.net,Asp.net Mvc,Asp.net Mvc 3,Mvcmailer,我正在使用MVC邮件器-我的控制器中有: // // POST: /ExhibitorInterest/Create [HttpPost] public ActionResult Create(ExhibitorInterest exhibitorinterest) { if (ModelState.IsValid) { db.ExhibitorInterests.Add(exhibitorinte
//
// POST: /ExhibitorInterest/Create
[HttpPost]
public ActionResult Create(ExhibitorInterest exhibitorinterest)
{
if (ModelState.IsValid)
{
db.ExhibitorInterests.Add(exhibitorinterest);
db.SaveChanges();
UserMailer.ExhibitorInterest().Send();
return RedirectToAction("Thankyou");
}
return View(exhibitorinterest);
}
但我想将模型参展商兴趣传递给mailer视图:
UserMailer.cs具有:
public virtual MvcMailMessage ExhibitorInterest()
{
//ViewBag.Data = someObject;
return Populate(x =>
{
x.Subject = "ExhibitorInterest";
x.ViewName = "ExhibitorInterest";
x.To.Add("me@myemail.co.uk");
});
}
你知道我是如何将exhibitorinterest添加到UserMailer.cs的吗?这样我就可以将它添加到邮件视图了
谢谢,
Mark我想我找到了答案-将IUSerMailer.cs的签名更改为:
public interface IUserMailer
{
MvcMailMessage ExhibitorInterest(ExhibitorInterest exhibitorinterest);
和UserMail.cs发送至:
public virtual MvcMailMessage ExhibitorInterest(ExhibitorInterest exhibitorinterest)
{
ViewBag.Data = exhibitorinterest.xxxxxxx;
希望它能帮助别人
谢谢,Mark我想我知道了-将IUSerMailer.cs的签名更改为:
public interface IUserMailer
{
MvcMailMessage ExhibitorInterest(ExhibitorInterest exhibitorinterest);
和UserMail.cs发送至:
public virtual MvcMailMessage ExhibitorInterest(ExhibitorInterest exhibitorinterest)
{
ViewBag.Data = exhibitorinterest.xxxxxxx;
希望它能帮助别人
谢谢,Mark我确实发布了类似的内容,但对GitHub中显示的基本示例感到困惑,并尝试使用最佳实践,因此如果这看起来像是一个转载,我表示歉意-我现在有3个邮件视图-其中一个在上面,因此对我来说越来越复杂,需要弄清楚并保持干净。谢谢。我确实发布了一些类似的东西——但对GitHub中显示的基本示例感到困惑——并尝试使用最佳实践——因此,如果这看起来像是一个转发,我表示歉意——我现在有3个邮件视图——其中一个在上面,因此对我来说越来越复杂,并且保持干净。非常感谢。