示例#1
0
        public ActionResult Contact(ContactViewModel userdata)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            var messageBody = string.Format("{0}{1}---{1}Sent by: {2}", userdata.Message,
                                            Environment.NewLine, userdata.GetNameDetails());
            var message = new MailMessage(EmailService.DefaultContactEmail, EmailService.DefaultContactEmail)
            {
                Body    = messageBody,
                Subject = "TeamReview.net - contact form"
            };
            var displayName = userdata.GetDisplayName();

            message.ReplyToList.Add(new MailAddress(userdata.EmailAddress, displayName));

            new SmtpClient().Send(message);

            TempData["MessageSent"] = "true";
            return(RedirectToAction("Contact"));
        }