public void sendContactFormEmail(VMContactForm VM) { // Using Google's SMTP SmtpClient client = new SmtpClient(); client.DeliveryMethod = SmtpDeliveryMethod.Network; client.EnableSsl = true; client.Host = "smtp.gmail.com"; client.Port = 587; System.Net.NetworkCredential credentials = new System.Net.NetworkCredential("*****@*****.**", "ztwxercx4321"); client.UseDefaultCredentials = false; client.Credentials = credentials; MailMessage msg = new MailMessage(); msg.From = new MailAddress(VM.Email); msg.To.Add(new MailAddress("*****@*****.**")); msg.Subject = "Board Game Sleeve - Contact FOrm"; msg.IsBodyHtml = true; msg.Body = string.Format("<html><head></head><body><strong>Name: </strong> " + VM.Name + "<br /><strong>Email: </strong> " + VM.Email + "<br /> <strong>Message: </strong> " + VM.Message + "</body></html>"); // Afsender mailen try { //most be on a secure connection aka a online server client.Send(msg); } catch (Exception) { } }
public ActionResult Contact(VMContactForm vm) { service.sendContactFormEmail(vm); ViewBag.signifier = "Thanks for the message we will contact your as fast as posseble"; VMContactForm vmNew = new VMContactForm(); return(View(vmNew)); }
public ActionResult Contact() { VMContactForm vm = new VMContactForm(); return(View(vm)); }