コード例 #1
0
        public ActionResult Contact(EmailSendingViewModel emailSendingViewModel)
        {
            EmailSender emailSender = new EmailSender();

            if (emailSendingViewModel.Email == null || emailSendingViewModel.Name == null || emailSendingViewModel.Comment == null)
            {
                TempData["Email"] = "You have to enter all the needed information for sending an email!";
                return(View("Contact"));
            }

            emailSender.SendContactFormEmail(emailSendingViewModel.Email, emailSendingViewModel.Name, emailSendingViewModel.Comment);
            TempData["Email"] = "You have send the email successfully!";

            return(View("Contact"));
        }
コード例 #2
0
        public ActionResult Contact(EmailSendingViewModel emailSendingViewModel)
        {
            EmailSender emailSender = new EmailSender();

            if (emailSendingViewModel.Body == null || emailSendingViewModel.From == null || emailSendingViewModel.Subject == null)
            {
                TempData["Email"] = "You have to enter all the needed information for sending an email!";
                return(View("Contact"));
            }

            emailSender.SendMail(emailSendingViewModel.From, emailSendingViewModel.Subject, emailSendingViewModel.Body);
            TempData["Email"] = "You have send the email successfully!";

            return(View("Contact"));
        }
コード例 #3
0
        public ActionResult Index(EmailSendingViewModel emailSendingViewModel)
        {
            EmailSender emailSender = new EmailSender();

            if (emailSendingViewModel.Comment == null || emailSendingViewModel.Name == null || emailSendingViewModel.Email == null)
            {
                ModelState.AddModelError("error_contact", "  You have to enter all the needed information for sending an email!");
                return(View());
            }
            else
            {
                emailSender.SendEmail(emailSendingViewModel.Email, emailSendingViewModel.Name, emailSendingViewModel.Comment);
                TempData["Email"] = "You have send the email successfully!";
                return(View("Contact"));
            }
        }