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
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