コード例 #1
0
        public ActionResult Contact(ContactModel model, bool captchaValid, string mobile, string captchaErrorMessage)
        {
            ViewBag.servicephone     = ServicePhone;
            TempData["SentIMEALMsg"] = "";
            if (ModelState.IsValid)
            {
                if (string.IsNullOrEmpty(mobile) || mobile != "y")
                {
                    if (!captchaValid)
                    {
                        ModelState.AddModelError("recaptcha", captchaErrorMessage);
                        return(View(model));
                    }
                }
                bool sendSuccess = false;
                //ViewBag.qqq = EmailManager.BuildCustomerEmailBody(model);
                EmailManager  em = new EmailManager();
                EmailContents ec = new EmailContents(model.ContactName, Globals.Settings.ContactForm.MailTo, model.Email,
                                                     "Customer Help", EmailManager.BuildCustomerEmailBody(model));

                // em.FaxBody = EmailManager.BuildCustomerEmailBody(model);
                //em.SendFax(WebConfigurationManager.AppSettings["OnlineFaxNumber"].ToString());
                em.Send(ec); // send to foodready.net
                if (em.IsSent == false)
                {
                    sendSuccess = false;
                    TempData["SentIMEALMsg"] = "Your message has not been sent out for some reasons.";
                }
                else
                {
                    sendSuccess = true;
                    TempData["SentIMEALMsg"] = "Your message has  been sent out successfully.";
                }
                ViewBag.SendingSuccess = sendSuccess;
                return(View(model));
            }
            return(View(model));
        }