Пример #1
0
        public ActionResult Contact(Contact contact)
        {
            if (ModelState.IsValid)
              {
            using (var client = new SmtpClient())
            {
              var from = new MailAddress("*****@*****.**", "JustBlog Messenger");
              var to = new MailAddress("*****@*****.**", "JustBlog Admin");

              using (var message = new MailMessage(from, to))
              {
            message.Body = contact.Body;
            message.IsBodyHtml = true;
            message.BodyEncoding = Encoding.UTF8;

            message.Subject = contact.Subject;
            message.SubjectEncoding = Encoding.UTF8;

            message.ReplyTo = new MailAddress(contact.Email);

            client.Send(message);
              }
            }

            return RedirectToAction("Posts");
              }

              return View();
        }
Пример #2
0
        public ViewResult Contact(Contact contact)
        {
            if (ModelState.IsValid)
            {
                using (var client = new SmtpClient())
                {
                    var adminEmail = ConfigurationManager.AppSettings["AdminEmail"];
                    var from = new MailAddress(adminEmail, "JustBlog Messenger");
                    var to = new MailAddress(adminEmail, "JustBlog Admin");

                    using (var message = new MailMessage(from, to))
                    {
                        message.Body = contact.Body;
                        message.IsBodyHtml = true;
                        message.BodyEncoding = Encoding.UTF8;

                        message.Subject = contact.Subject;
                        message.SubjectEncoding = Encoding.UTF8;

                        message.ReplyTo = new MailAddress(contact.Email);

                        client.Send(message);
                    }
                }

                return View("Thanks");
            }

            return View();
        }