I want to send email using an MVC 3 application. I have a user table named Reviewer in a database with email addresses. What I want is when I select 2-3 users from the table on the view using checkboxes, the email address for each user should be inserted automatically into the "Textbox" on the feedback view page, but it's not working. It's taking the value of Webmail.Send() from the controller instead of the feedback form page. Any ideas?
[HttpPost]
public ActionResult Feedback(string email, string subject, string body)
{
try
{
WebMail.SmtpServer = "smtp.gmail.com";
WebMail.EnableSsl = true;
WebMail.SmtpPort = 25;
WebMail.UserName = "[email protected]";
WebMail.Password = "*******123";
WebMail.From = "[email protected]";
WebMail.Send(
"[email protected]",
subject,
body,
email
);
return RedirectToAction("FeedbackSent");
}
catch (Exception ex)
{
ViewData.ModelState.AddModelError("_FORM", ex.ToString());
}
return View();
}
This is the View page of Feedback:
@using(Html.BeginForm()) {
<table>
<tr>
<td>Your e-mail:</td>
<td>@Html.TextBox("email")</td>
</tr>
<tr>
<td>Subject:</td>
<td>@Html.TextBox("subject")</td>
</tr>
<tr>
<td>Body:</td>
<td>@Html.TextArea("body")</td>
</tr>
</table>
<input type="submit" value="Send" />
}
[email protected]instead of what was entered in the form?