public ActionResult DenemeForm(Wissen.Models.DenemeForm model) { if (ModelState.IsValid) { bool hasError = false; try { //1000:Mail gönder System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage(); mailMessage.From = new System.Net.Mail.MailAddress("*****@*****.**", "tano"); mailMessage.Subject = "İletişim Formu: " + model.FirstName + " " + model.LastName; mailMessage.To.Add("[email protected],[email protected]"); string body; body = "Ad: " + model.FirstName + "<br />"; body = "Soyad: " + model.LastName + "<br />"; body += "Telefon: " + model.Phone + "<br />"; body += "E-posta: " + model.Email + "<br />"; mailMessage.IsBodyHtml = true; mailMessage.Body = body; System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.gmail.com", 587); smtp.Credentials = new System.Net.NetworkCredential("mail", "sifre"); smtp.EnableSsl = true; smtp.Send(mailMessage); ViewBag.Message = "Mesajınız gönderildi. Teşekkür ederiz."; } catch (Exception ex) { ModelState.AddModelError("Error", ex.Message); hasError = true; } if (hasError == false) { ViewBag.Message = "Mail başarıyla gönderildi."; return(View()); } } return(View()); }
public ActionResult DenemeForm(Wissen.Models.DenemeForm model) { if (ModelState.IsValid) { bool hasError = false; try { // TODO: Mail gönder throw new Exception("Maile sunucusuna ulaşılamıyor! Lütfen daha sonra tekrar deneyin."); } catch (Exception ex) { ModelState.AddModelError("Error", ex.Message); hasError = true; } if (hasError == false) { ViewBag.Message = "Mail başarıyla gönderildi"; } return(View()); } return(View()); }
public ActionResult DenemeForm(Wissen.Models.DenemeForm model1) { if (ModelState.IsValid) { bool hasError = false; try { System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage(); mailMessage.From = new System.Net.Mail.MailAddress("*****@*****.**", "ali"); mailMessage.Subject = "İletişim Formu: " + model1.firstName + "" + model1.LastName; mailMessage.To.Add("[email protected] [email protected]"); string body; body = "Ad Soyad: " + model1.firstName + "<br />"; body += "Telefon: " + model1.LastName + "<br />"; body += "E-posta: " + model1.Email + "<br />"; body += "Telefon: " + model1.Phone + "<br />"; mailMessage.IsBodyHtml = true; mailMessage.Body = body; System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.gmail.com", 587); smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "34ff6229"); smtp.EnableSsl = true; smtp.Send(mailMessage); ViewBag.Message = "Mesajınız gönderildi. Teşekkür ederiz."; } catch (Exception ex) { ModelState.AddModelError("Error", ex.Message); hasError = true; } if (hasError == false) { ViewBag.Message = "mail gonderildi galiba mail adresini kontrol et"; } return(View()); } return(View()); }