title: MvcMailer: Taking user input in view through model and then inserting it into mail
body: <p>I don't know if I am explaining this correctly, or if the solution is rather simple, so here goes:</p>
  
  <p>I am using MvcMailer, but before that I set up a wizard input form which I call Quote.cshtml. Behind Quote.cshtml, I set up a model called QuoteModel.cs.</p>
  
  <p>Quote.cshtml at its most basic (I am leaving out all of the wizard logic and only showing one input):</p>
  
  <pre><code>&lt;td width="40%"&gt;
      @Html.LabelFor(m =&gt; m.FirstName, new { @class = "mylabelstyle", title = "Enter first name." })
  &lt;/td&gt;
  &lt;td width="60%"&gt;
      @Html.TextBoxFor(m =&gt; m.FirstName)
      @Html.ValidationMessageFor(m =&gt; m.FirstName)
  &lt;/td&gt;
  </code></pre>
  
  <p>QuoteModel.cs (again, only showing the one input; n.b.: using the <a href="http://dataannotationsextensions.org/" rel="noreferrer">DataAnnotationExtensions</a>)</p>
  
  <pre><code>public class QuoteModel
  { 
      [Required(ErrorMessage = "First Name required.")]
      [Display(Name = "First Name:")]
      public string FirstName { get; set; }
  }
  </code></pre>
  
  <p>Now I am trying to integrate MvcMailer, which sets up IQuoteMailer.cs, QuoteMailer.cs, _Layout.cshtml, and QuoteMail.cshtml.  The QuoteMail.cshtml is what the recipient of the mail will eventually see. I also set up a QuoteController.cs, in which I placed the appropriate code required by MvcMailer. It is in the QuoteMailer.cs and QuoteController.cs where I am having trouble passing the user input from Quote.cshtml (which is based on the model in QuoteModel.cs).</p>
  
  <p>IQuoteMailer.cs:</p>
  
  <pre><code> public interface IQuoteMailer
      {               
           MailMessage QuoteMail();
      }
  </code></pre>
  
  <p>QuoteMailer.cs:</p>
  
  <pre><code>public class QuoteMailer : MailerBase, IQuoteMailer     
  {
      public QuoteMailer():
          base()
      {
          MasterName="_Layout";
      }
  
  
      public virtual MailMessage QuoteMail()
      {
          var mailMessage = new MailMessage{Subject = "QuoteMail"};
  
          mailMessage.To.Add("some-email@example.com");
          ViewBag.Data = someObject; 
                      //I imagine this is where I can pass my model, 
                      //but I am not sure (do I have to iterate each and
                      //every input (there are like 20 in QuoteModel.cs)?
  
                  return mailMessage;
      }
  </code></pre>
  
  <p>QuoteMail.cshtml (_Layout.cshtml is pretty standard, so not showing here):</p>
  
  <pre><code>@*HTML View for QuoteMailer#QuoteMail*@
  
  Welcome to MvcMailer and enjoy your time!&lt;br /&gt;
  &lt;div class="mailer_entry"&gt;
      &lt;div class="mailer_entry_box"&gt;
          &lt;div class="mailer_entry_text"&gt;
              &lt;h2&gt;
                  INSERT_TITLE
              &lt;/h2&gt;
              &lt;p&gt;
                  INSERT_CONTENT
                  //I believe I am going to use a "@" command like @ViewData
                  //to pass FirstName, but again, not sure how to bind 
                  //the model and then pass it.
              &lt;/p&gt;
              &lt;p&gt;
                  INSERT_CONTENT
              &lt;/p&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>And finally, the relevant parts of the QuoteController.cs (note that I have am using a wizard, therefore, part of my problem is figuring out where to put the MvcMailer code, but I think I may have it right):</p>
  
  <p>public class QuoteController: Controller
      {</p>
  
  <pre><code>    /// &lt;summary&gt;
      /// MvcMailer
      /// &lt;/summary&gt;
      private IQuoteMailer _quoteMailer = new QuoteMailer();
      public IQuoteMailer QuoteMailer
      {
          get { return _quoteMailer; }
          set { _quoteMailer = value; }
      }
  
      //
      // GET: /Quote/
      [HttpGet]
      public ActionResult Quote()
      {
          HtmlHelper.ClientValidationEnabled = true;
          HtmlHelper.UnobtrusiveJavaScriptEnabled = true;
          //In order to get the clientside validation (unobtrusive), 
          //the above lines are necessary (where action takes place)
          return View();
      }
  
      //
      // POST: /Matrimonial/
      [HttpPost]
      public ActionResult Quote(QuoteModel FinishedQuote)
      {
          if (ModelState.IsValid)
          {
              QuoteMailer.QuoteMail().Send();
              return View("QuoteMailSuccess", FinishedQuote);
          }
          else return View();
      }
  
      //
      // POST: /Matrimonial/Confirm
      [HttpPost]
      public ActionResult QuoteMailConfirm(QuoteModel FinishedQuote)
      {
          return PartialView(FinishedQuote);
      }
  </code></pre>
  
  <p>}</p>
  
  <p>So, my confusion is to how to pass the QuoteModel I created, so that ultimately I can take the user inputed data and then generate the MvcMailer view.</p>
  
  <p>I appreciate the communities help.</p>