title: Send Email with data (ASP.NET mvc)
body: <p>I need to make sending Email by button click.</p>
  
  <p>I make Model for Email</p>
  
  <pre><code>public class MailModel
  {
      public string From { get; set; }
      public string To { get; set; }
      public string Subject { get; set; }
      public string Body { get; set; }
      public bool IsShowAlert { get; set; }
  }
  </code></pre>
  
  <p>And make method in Controller like this</p>
  
  <pre><code> [HttpPost]
          public ViewResult Index(Models.MailModel _objModelMail)
          {
              if (ModelState.IsValid)
              {
                  MailMessage mail = new MailMessage();
                  mail.To.Add(_objModelMail.To);
                  mail.From = new MailAddress(_objModelMail.From);
                  mail.Subject = _objModelMail.Subject;
                  string Body = _objModelMail.Body;
                  mail.Body = Body;
                  mail.IsBodyHtml = true;
                  SmtpClient smtp = new SmtpClient();
                  smtp.Host = "smtp.gmail.com";
                  smtp.Port = 587;
                  smtp.UseDefaultCredentials = false;
                  smtp.Credentials = new System.Net.NetworkCredential
                  ("suhomlin.eugene95@gmail.com", "dontoretto23");// Enter seders User name and password
                  smtp.EnableSsl = true;
                  smtp.Send(mail);
  
                  return View("Index", (IEnumerable&lt;Clients&gt;) _objModelMail);
              }
              else
              {
                  return View();
              }
          }
  </code></pre>
  
  <p>All work's when I create new view for Email.</p>
  
  <p>But I need to do this not in new view.</p>
  
  <p>Here is my View design
  <a href="https://i.stack.imgur.com/VfASO.png" rel="nofollow noreferrer">Screen</a></p>
  
  <p>Here is code of View </p>
  
  <pre><code>  @model IEnumerable&lt;SmartSolutions.Models.Clients&gt;
  
  @{
      Layout = "~/Views/Shared/_Layout2.cshtml";
  }
  
  @{
      ViewBag.Title = "Список клиентов";
  }
  
  
  
  
  
  &lt;table class="table"&gt;
      @{int rowNo = 0;}
  
  
  
      &lt;tr style="background: #d1d3d4"&gt;
          &lt;th&gt;&lt;/th&gt;
          &lt;th style="font-size: 20px; text-align: center;"&gt;
              @Html.DisplayNameFor(model =&gt; model.Email)
          &lt;/th &gt;
          &lt;th style="font-size: 20px; text-align: center;"&gt;
              @Html.DisplayNameFor(model =&gt; model.UserName)
          &lt;/th&gt;
          &lt;th style="font-size: 20px; text-align: center;"&gt;
              @Html.DisplayNameFor(model =&gt; model.Position)
          &lt;/th&gt;
  
          &lt;th&gt;&lt;/th&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td style="height: 40px; width: 40px; background: red;"&gt;
              &lt;a href='@Url.Action("Create", "Clients")'&gt;
                  &lt;img style="object-fit: cover;" src='@Url.Content("~/Images/plus.png")' /&gt;
              &lt;/a&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
      @foreach (var item in Model)
      {
  
          &lt;tr &gt;
              &lt;td class="point"&gt;
                  @(rowNo += 1)
              &lt;/td&gt;
              &lt;td style="text-align: center; font-size: 18px;"&gt;
                  @Html.DisplayFor(modelItem =&gt; item.Email)
              &lt;/td&gt;
              &lt;td style="text-align: center; font-size: 18px;"&gt;
                  @Html.DisplayFor(modelItem =&gt; item.UserName)
              &lt;/td&gt;
              &lt;td style="text-align: center; font-size: 18px;"&gt;
                  @Html.DisplayFor(modelItem =&gt; item.Position)
              &lt;/td&gt;
  
              &lt;td style="text-align: end;"&gt;
  
  
                  @Html.ActionLink("Отправить приглашение", "Details", new {id = item.ID}, new {@class = "sendinviteclass"})
  
  
                  &lt;a href='@Url.Action("Edit", "Clients", new {id = item.ID})'&gt;
                      &lt;img src='@Url.Content("~/Images/Edit.png")'/&gt;
                  &lt;/a&gt;
                  &lt;!-- @Html.ActionLink("Редактировать", "Edit", new {id = item.ID}, new {@class = "editclass"})--&gt;
                  &lt;a href='@Url.Action("Delete", "Clients", new {id = item.ID})'&gt;
                      &lt;img src='@Url.Content("~/Images/Delete.png")'/&gt;
                  &lt;/a&gt;
  
              &lt;/td&gt;
          &lt;/tr&gt;
      }
  
  &lt;/table&gt;
  </code></pre>
  
  <p>When I click to marked button, I need  to send email to adress that is on EMAIL column with default text.</p>
  
  <p>Marked button is button in table.</p>
  
  <p>Default text is smth like "You added to system go to testwebsite.com. Your password is <code>PasswordField</code> in database." </p>
  
  <p>Here is Clients model</p>
  
  <pre><code> public class Clients
  {
      public int ID { get; set; }
      [Required]
      [Display(Name = "Email")]
      [EmailAddress]
      public string Email { get; set; }
      [Display(Name = "Ф.И.О")]
      public string UserName { get; set; }
      [Display(Name = "Должность")]
      public string Position { get; set; }
      [Required]
      [DataType(DataType.Password)]
      [Display(Name = "Пароль")]
      public string Password { get; set; }
  
  
  }
  </code></pre>
  
  <p>How I can do this?</p>