public ActionResult Index(ContactModel model) { // Hiện tại không dùng if (ModelState.IsValid) { const string smtpUserName = "******"; const string smtpPassword = "******"; const string smptHost = "smtp.gmail.com"; const int smtpPort = 25; const string emailTo = "*****@*****.**"; var subject = model.Subject; var body = string.Format("Bạn vừa nhận được liên hệ từ: <b>{0}</b><br/>Email:{1}<br/>Nội dung:<br/>{2}", model.UserName, model.Email, model.Message); var service = new EmailService(); var kq = service.Send(smtpUserName, smtpPassword, smptHost, smtpPort, emailTo, subject, body); ModelState.AddModelError("", kq ? "Cảm ơn bạn đã liên hệ với Topmito" : "Gửi email thất bại, vui lòng gửi lại."); } return View(model); }
// // GET: /Admin/SendMail/ public ActionResult Index() { var model = new ContactModel(); return View(model); }