public ActionResult Contact()
 {
     var model = new ContactModel()
     {
         Email = _workContext.CurrentCustomer.Email,
         FirstName = _workContext.CurrentCustomer.GetAttribute<string>(SystemCustomerAttributeNames.FirstName),
         Surname = _workContext.CurrentCustomer.GetAttribute<string>(SystemCustomerAttributeNames.LastName),
         Telephone = _workContext.CurrentCustomer.GetAttribute<string>(SystemCustomerAttributeNames.Phone),
         DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnContactUsPage
     };
     return View(model);
 }
        public ActionResult ContactUsSend(ContactModel model, bool captchaValid)
        {
            //validate CAPTCHA
            if (_captchaSettings.Enabled && _captchaSettings.ShowOnContactUsPage && !captchaValid)
            {
                ModelState.AddModelError("", _localizationService.GetResource("Common.WrongCaptcha"));
            }

            if (ModelState.IsValid)
            {
                string email = model.Email.Trim();
                string firstname = model.FirstName.Trim();
                string surname = model.Surname.Trim();
                string fullName = string.Format("{0} {1}", firstname, surname);
                string telephone = model.Telephone.Trim();
                string orderRef = model.OrderReference.Trim();
                string subject = string.Format(_localizationService.GetResource("ContactUs.EmailSubject"), _storeInformationSettings.StoreName);

                var emailAccount = _emailAccountService.GetEmailAccountById(_emailAccountSettings.DefaultEmailAccountId);
                if (emailAccount == null)
                    emailAccount = _emailAccountService.GetAllEmailAccounts().FirstOrDefault();

                string from = null;
                string fromName = null;

                StringBuilder body = new StringBuilder();
                body.Append("<html><head><title>Email Enquiry</title></head><body>");
                body.Append("<b>First Name:</b> " + firstname + "<br />");
                body.Append("<b>Surname:</b> " + surname + " <br />");
                body.Append("<b>Email:</b> " + email + " <br />");
                body.Append("<b>Telephone:</b> " + telephone + " <br />");
                body.Append("<b>Order Reference:</b> " + orderRef + " <br />");
                body.Append("<b>Enquiry:</b><br /> " + model.Enquiry);
             //   string body = Core.Html.HtmlHelper.FormatText(model.Enquiry,
                //required for some SMTP servers
                if (_commonSettings.UseSystemEmailForContactUsForm)
                {
                    from = emailAccount.Email;
                    fromName = emailAccount.DisplayName;
                }
                else
                {
                    from = email;
                    fromName = fullName;
                }
                _queuedEmailService.InsertQueuedEmail(new QueuedEmail()
                {
                    From = from,
                    FromName = fromName,
                    To = emailAccount.Email,
                    ToName = emailAccount.DisplayName,
                    Priority = 5,
                    Subject = subject,
                    Body = body.ToString(),
                    CreatedOnUtc = DateTime.UtcNow,
                    EmailAccountId = emailAccount.Id
                });

                model.SuccessfullySent = true;
                model.Result = _localizationService.GetResource("ContactUs.YourEnquiryHasBeenSent");
                return View(model);
            }

            model.DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnContactUsPage;
            return View(model);
        }