public ActionResult SendEmail(FamilyPlanner.Models.SendEmail model) { try { MailMessage Msg = new MailMessage(); Msg.From = new MailAddress(model.From); Msg.To.Add(model.To); Msg.Subject = model.Text; Msg.Body = model.Text; SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; smtp.Port = 587; smtp.Credentials = new System.Net.NetworkCredential(model.From, model.Password); smtp.EnableSsl = true; smtp.Send(Msg); ViewBag.Status = "Email Sent Successfully."; } catch (Exception) { ViewBag.Status = "Problem while sending email, Please check details."; } return(View()); }
//GET: SendEmails public ActionResult Index(FamilyPlanner.Models.SendEmail model) { return(View(db.SendEmail.ToList())); }