0

I'm using the MVC Mailer - I have this in my controller:

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

But I want to pass the model exhibitorinterest to the mailer view:

The UserMailer.cs has:

public virtual MvcMailMessage ExhibitorInterest()
    {
        //ViewBag.Data = someObject;
        return Populate(x =>
        {
            x.Subject = "ExhibitorInterest";
            x.ViewName = "ExhibitorInterest";
            x.To.Add("me@myemail.co.uk");
        });
    }

Any ideas how I get exhibitorinterest into the UserMailer.cs - so I can add it to the mail view please?

Thank you,

Mark

Mark
  • 7,778
  • 24
  • 89
  • 147
  • I did post something similar - but have got confused over the basic example shown in GitHub - and trying to use best practice - so apologies if this seems like a repost - I've now got 3 mail views - one of which is above, so is getting more complicated for me to figure out, and keep it clean. Thank you. – Mark Oct 05 '12 at 20:43

1 Answers1

3

Think I figured it out - change the signature of IUSerMailer.cs to:

public interface IUserMailer
{
 MvcMailMessage ExhibitorInterest(ExhibitorInterest exhibitorinterest); 

And UserMail.cs to:

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

Hope it helps someone else.

Thanks, Mark

Mark
  • 7,778
  • 24
  • 89
  • 147