private RedirectToRouteResult SendRegistratioMessage(RegistrationForm model) { var body = @"<p>Workshop Title: {0}</p> <p>First Name: {1}</p> <p>Last Name: {2}</p> <p>Email Address: {3}</p> <p>Telephone Number: {4}</p>"; var message = new MailMessage(); message.To.Add(new MailAddress("*****@*****.**")); message.From = new MailAddress("*****@*****.**"); message.Subject = String.Format("{0} {1} wants to register for: {2}.", model.FirstName, model.LastName, model.LabName); message.Body = String.Format(body, model.LabName, model.FirstName, model.LastName, model.Email, model.Telephone); message.IsBodyHtml = true; using (var smtp = new SmtpClient()) { var credential = new NetworkCredential { UserName = "******", Password = "******" }; smtp.Credentials = credential; smtp.Host = "smtp.kongresrodzinychicago.org"; smtp.Port = 587; smtp.EnableSsl = false; smtp.Send(message); return RedirectToAction("Donacja", "Home", new { FromRegistration = true }); } }
public ActionResult Rejestracja(RegistrationForm model) { if (ModelState.IsValid) { return SendRegistratioMessage(model); } return View(model); }