示例#1
0
        public ActionResult Index(EmailModel m)
        {
            if (TryValidateModel(m) && !m.IsSpam)
            {
                var email = new EmailModel();

                email.FromEmail = Config.Current.EmailNoReply.Address;
                email.FromName = m.FromName;
                email.Subject = m.Subject;
                email.Message = m.Message;
                try
                {
                    var mailAddr = new MailAddress(m.FromEmail);
                }
                catch (Exception)
                {
                    ModelState.AddModelError("FromEmail", "Please input valid email address");
                    return View(m);
                }

                email.ReplyToAddress = m.FromEmail;

                var emailService = new EmailService();
                emailService.SendEmail(email);

                return View("EmailSent");
            }
            return View(m);
        }
示例#2
0
        public ActionResult Index(ReferFriendModel m)
        {
            if(TryValidateModel(m) && !m.IsSpam)
            {
                var email = new EmailModel();

                email.FromEmail = Config.Current.EmailNoReply.Address;
                email.FromName = m.Name;
                email.Subject = "Refer a friend";
                email.Message = "Friend's name: " + m.FriendName + ",<br /> Friend's phone number: " + m.Phone + "<br /> My name: " + m.Name ;
                email.ReplyToAddress = email.FromEmail;

                var emailService = new EmailService();
                emailService.SendEmail(email);
                return View("Submitted");
            }
            return View(m);
        }