0

我正在使用 MVC Mailer - 我的控制器中有这个:

    //
    // 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);
    }

但我想将模型参展商兴趣传递给邮件视图:

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");
        });
    }

任何想法如何让参展商对 UserMailer.cs 感兴趣 - 所以我可以将它添加到邮件视图中吗?

谢谢,

标记

4

1 回答 1

3

想我想通了 - 将 IUSerMailer.cs 的签名更改为:

public interface IUserMailer
{
 MvcMailMessage ExhibitorInterest(ExhibitorInterest exhibitorinterest); 

和 UserMail.cs 到:

public virtual MvcMailMessage ExhibitorInterest(ExhibitorInterest exhibitorinterest)
{
 ViewBag.Data = exhibitorinterest.xxxxxxx;

希望它可以帮助别人。

谢谢,马克

于 2012-10-05T21:39:43.477 回答