コード例 #1
0
        public void Send(Contact contact)
        {
            MailMessage mail = new MailMessage(
                ConfigurationManager.AppSettings["MailFrom"],
                ConfigurationManager.AppSettings["MailTo"],
                "Enquiry via website djstephaniejay.com",
                contact.From + "\r\n\r\n" + contact.ContactVia + "\r\n\r\n" + contact.Message);

            new SmtpClient().Send(mail);
        }
コード例 #2
0
        public ActionResult Index(ContactViewModel contactVM)
        {
            if (!ModelState.IsValid)
            {
                return View(contactVM);
            }

            var contact = new Contact
            {
                From = contactVM.From,
                ContactVia = contactVM.ContactVia,
                Message = contactVM.Message
            };

            new Email().Send(contact);

            return RedirectToAction("ContactConfirm");
        }