/// <summary> /// Prepare the contact us model /// </summary> /// <param name="model">Contact us model</param> /// <param name="excludeProperties">Whether to exclude populating of model properties from the entity</param> /// <returns>Contact us model</returns> public virtual ContactUsModel PrepareContactUsModel(ContactUsModel model, bool excludeProperties) { if (model == null) { throw new ArgumentNullException(nameof(model)); } if (!excludeProperties) { if (_httpContextAccessor.HttpContext.User.Identity.IsAuthenticated) { System.Security.Claims.ClaimsPrincipal userClaimsPrincipal = _httpContextAccessor.HttpContext.User; ApplicationUser user = _userManager.Users.FirstOrDefault(x => x.UserName == userClaimsPrincipal.Identity.Name); if (user != null) { model.Email = user.Email; model.FullName = user.FirstName + user.LastName; } } } model.SubjectEnabled = true; return(model); }
public void Should_not_have_error_when_enquiry_is_specified() { var model = new ContactUsModel(); model.Enquiry = "please call me back"; _validator.ShouldNotHaveValidationErrorFor(x => x.Enquiry, model); }
public ActionResult ContactUsWeb(ContactUsModel ObjModel) { String Response = string.Empty; if (ModelState.IsValid) { string body = "Thanks For Submit Request"; string emailId = ObjModel.Email; string subject = "Contact Us"; string userName = ObjModel.FullName; string Password = ""; var _request = JsonConvert.SerializeObject(ObjModel); ResponseModel ObjResponse = CommonFile.GetApiResponse(Constant.ApiSaveContactUs, _request); int respo = CommonFile.SendMailContact(emailId, subject, userName, Password, body); Response = "[{\"Response\":\"" + respo + "\"}]"; if (String.IsNullOrWhiteSpace(ObjResponse.Response)) { return(View("Index", ObjModel)); } ViewBag.ResponseMessage = "Your Request has been submit"; //ObjModel.Email = string.Empty; //ObjModel.FullName = string.Empty; //ObjModel.Message = string.Empty; ModelState.Clear(); return(View("Index")); } return(View("Index", ObjModel)); }
public async Task <IViewComponentResult> InvokeAsync(string widgetZone, object additionalData = null) { var topicSystemName = (string)additionalData; if (topicSystemName != "contact-us") { return(Content("")); } var model = new ContactUsModel(); var customerAddress = (await _customerService.GetAddressesByCustomerIdAsync( (await _workContext.GetCurrentCustomerAsync()).Id )).FirstOrDefault(); //prefilling based on customer address if (customerAddress != null) { model.Name = customerAddress.FirstName + ' ' + customerAddress.LastName; model.Email = customerAddress.Email; model.PhoneNumber = customerAddress.PhoneNumber; } PrepareContactReasonsAndStores(ref model); model.DisplayCaptcha = _captchaSettings.Enabled; return(View("~/Plugins/Widgets.AbcContactUs/Views/ContactUs.cshtml", model)); }
private void PrepareContactReasonsAndStores(ref ContactUsModel model) { model.ReasonsForContact.Add(new SelectListItem { Text = "Comment", Value = "Comment" }); model.ReasonsForContact.Add(new SelectListItem { Text = "Inquiry", Value = "Inquiry" }); model.ReasonsForContact.Add(new SelectListItem { Text = "Solicitation", Value = "Solicitation" }); model.ReasonsForContact.Add(new SelectListItem { Text = "Complaint", Value = "Complaint" }); model.Reason = model.ReasonsForContact.First().Value; model.Stores.Add(new SelectListItem { Text = "Website", Value = "Website" }); foreach (var shop in _shopRepository.Table) { model.Stores.Add(new SelectListItem { Text = shop.Name, Value = shop.Name }); } model.SelectedStore = model.Stores.First().Value; model.DisplayCaptcha = _captchaSettings.Enabled; }
public HttpResponseMessage SaveContactUs(ContactUsModel contactus) { try { if (this.ModelState.IsValid) { var contact = service.SaveContactUs(contactus); if (contact != null) { return(Request.CreateResponse(HttpStatusCode.OK, contact)); } else { string message = "Error Saving Data"; return(Request.CreateErrorResponse(HttpStatusCode.Forbidden, message)); } } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.InnerException.Message)); } }
public HttpResponseMessage DeleteContactUs(ContactUsModel contactus) { try { if (this.ModelState.IsValid) { var result = service.DeleteContactUs(contactus); if (result != null) { return(Request.CreateResponse(HttpStatusCode.OK, result)); } else { string message = "Not deleted successfully"; return(Request.CreateErrorResponse(HttpStatusCode.Forbidden, message)); } } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex)); } }
public ActionResult Edit([DataSourceRequest] DataSourceRequest request, FormCollection collection) { ContactUsModel contactUsModel = new ContactUsModel(); try { contactUsModel.Id = Convert.ToInt32(collection["models[0].Id"]); contactUsModel.Contact = collection["models[0].Contact"]; contactUsModel.Title = collection["models[0].Title"]; contactUsModel.Name = collection["models[0].Name"]; contactUsModel.Email = collection["models[0].Email"]; // TODO: Add update logic here if (collection != null && ModelState.IsValid) { var item = DB.ContactUs.FirstOrDefault(x => x.Id == contactUsModel.Id); if (item != null) { DB.Entry(item).CurrentValues.SetValues(contactUsModel); DB.SaveChanges(); return(RedirectToAction("Index")); } } return(Json(new[] { contactUsModel }.ToDataSourceResult(request, ModelState))); } catch { return(Json(new[] { contactUsModel }.ToDataSourceResult(request, ModelState))); } }
public async Task <ActionResult> ContactUs(ContactUsModel xyz) { if (ModelState.IsValid) { var body = "<p>Email From: {1}</p><p>Hello,</p><p>{2}</p><br><p>Regards,</p><p>{0}</p>"; var Message = new MailMessage(); Message.To.Add(new MailAddress("*****@*****.**")); Message.From = new MailAddress(xyz.EmailID); Message.Subject = xyz.Subject; Message.Body = string.Format(body, xyz.FullName, xyz.EmailID, xyz.Comments); Message.IsBodyHtml = true; using (var smtp = new SmtpClient()) { var credential = new NetworkCredential { UserName = "******", Password = "******" }; smtp.Credentials = credential; smtp.Host = "smtp.gmail.com"; smtp.Port = 587; smtp.EnableSsl = true; await smtp.SendMailAsync(Message); } } return(View()); }
public ActionResult Contact(string id) { var model = new ContactUsModel(); model.insert = id; return(View(model)); }
public ActionResult Create(FormCollection collection) { try { if (ModelState.IsValid) { ContactUsModel contactUsModel = new ContactUsModel(); contactUsModel.Contact = collection["models[0].Contact"]; contactUsModel.Title = collection["models[0].Title"]; contactUsModel.Name = collection["models[0].Name"]; contactUsModel.Email = collection["models[0].Email"]; DB.ContactUs.Add(contactUsModel); DB.SaveChanges(); return(RedirectToAction("Index")); } //The model is invalid - render the current view to show any validation errors return(View("Index")); } catch { return(View()); } }
public ActionResult SendEmail(FormCollection collection, ContactUsModel contact) { if (ModelState.IsValid) { var name = collection["Name"]; var emailContact = collection["Email"]; var subject = collection["Subject"]; var content = collection["Content"]; //var contact = new EmailController(_email).GetEmailConfig(); //var to = contact.To; //var from = contact.From; //var password = contact.Password; //var smtpPort = contact.SMTPPort; //var enableSSL = contact.EnableSSL; var html = string.Format(@"<table style='text-align: left;'> <tr><td colspan='2'>Thư góp ý.</td></tr><tr> <tr><td>Gửi từ:</td><td>{0} </td> </tr> <tr><td>Email:</td><td>{1}</td> </tr> <tr><td>Tiêu đề:</td><td>{2}</td></tr> <tr><td>Nội dung:</td><th></th></tr><tr><td colspan='2'>{3}</td></tr> </table>", contact.Name, contact.Email, contact.Subject, contact.Content); var result = new EmailController(_email).SendEmail("Thư góp ý", html); @TempData["result"] = result == true ? "Email gửi thành công" : "Email không gửi được."; } return(Redirect("~/#/lien-he")); }
public ActionResult ContactUs() { var viewModel = new ContactUsModel(); viewModel.Session = Session; return(View(viewModel)); }
public void ContactUsInsert(ContactUsModel model) { using (var dbctx = DbContext) { dbctx.ContactUsInsert(model.Name, model.PhoneNumber, model.EmailAddress, model.Message); } }
public HttpResponseMessage SubmitQuery(ContactUsModel model) { model.UserID = LOGGED_IN_USER.UserId; var data = _userManager.RequestContactUs(model); return(new JsonContent(data).ConvertToHttpResponseOK()); }
public virtual ActionResult ContactUsSend(ContactUsModel model, bool captchaValid) { //validate CAPTCHA if (_captchaSettings.Enabled && _captchaSettings.ShowOnContactUsPage && !captchaValid) { ModelState.AddModelError("", _captchaSettings.GetWrongCaptchaMessage(_localizationService)); } model = _commonModelFactory.PrepareContactUsModel(model, true); if (ModelState.IsValid) { string subject = _commonSettings.SubjectFieldOnContactUsForm ? model.Subject : null; string body = Core.Html.HtmlHelper.FormatText(model.Enquiry, false, true, false, false, false, false); string email = null; string phone = null; if (!string.IsNullOrWhiteSpace(model.Email)) { email = model.Email; } if (!string.IsNullOrWhiteSpace(model.Phone)) { phone = model.Phone; } try { _workflowMessageService.SendContactUsMessage(_workContext.WorkingLanguage.Id, email, model.FullName, subject, body, model.Phone); } catch { } model.SuccessfullySent = true; model.Result = _localizationService.GetResource("ContactUs.YourEnquiryHasBeenSent"); //activity log _customerActivityService.InsertActivity("PublicStore.ContactUs", _localizationService.GetResource("ActivityLog.PublicStore.ContactUs")); try { _emailSender.SendSmS(phone, _storeContext.CurrentStore.SmsLeadMsg, _storeContext.CurrentStore.SmsUserName, _storeContext.CurrentStore.SmsPassword, "", _storeContext.CurrentStore.SmsSender); NewsLetterSubscription subscription = new NewsLetterSubscription { NewsLetterSubscriptionGuid = Guid.NewGuid(), Email = email, phone = phone, name = model.FullName, subject = subject, Active = false, StoreId = _storeContext.CurrentStore.Id, CreatedOnUtc = DateTime.UtcNow }; _newsLetterSubscriptionService.InsertNewsLetterSubscription(subscription); } catch { } return(View(model)); } return(View(model)); }
public async Task <ActionResult> ContactUs(ContactUsModel model) { if (ModelState.IsValid) { var body = "<p>Email From: {0} ({1})</p><p>Message:</p><p>{2}</p>"; var message = new MailMessage(); message.To.Add(new MailAddress("*****@*****.**")); // replace with valid value message.From = new MailAddress("*****@*****.**"); // replace with valid value message.Subject = "Your email subject"; message.Body = string.Format(body, model.FromName, model.FromEmail, model.Message); message.IsBodyHtml = true; using (var smtp = new SmtpClient()) { smtp.Host = "smtp.gmail.com"; smtp.Port = 587; smtp.Credentials = new System.Net.NetworkCredential ("*****@*****.**", "sheridan18$"); smtp.EnableSsl = true; smtp.Send(message); return(RedirectToAction("Index")); } } return(View(model)); }
public void SerdEmail(string ProviderEmail, ContactUsModel contactUsModel) { var root = ConfigurationManager.AppSettings["root"]; MailMessage mail = new MailMessage(); mail.To.Add("*****@*****.**"); //mail.To.Add(ProviderEmail); mail.From = new MailAddress(ConfigurationManager.AppSettings["AdminEmail"]); mail.Subject = "Service Request"; mail.SubjectEncoding = System.Text.Encoding.UTF8; mail.Body = "<table border='1' rules='all' width='600'><tr><th>Consumer Name:</th><td>" + contactUsModel.FirstName + " " + contactUsModel.LastName + "</td></tr><tr><th>Service Date</th><td>" + contactUsModel.AppointmentDate + "</td></tr><tr><th>Best Time</th><td>" + contactUsModel.AppointmentTime; mail.Body += "</td></tr><tr><th>Invitation Options</th><td style='height: 40px;'>"; //mail.Body += "Consumer wants your services in "+serviceRequestModel.City+" City With Zipcode "+serviceRequestModel.ZipCode+" on "+serviceRequestModel.ServiceDate+ "<br/><br/>"; //mail.Body += "<a style='margin-right: 3px; padding: 7px;background-color:darkgreen; color: white' href='" + root + "/Consumer/ProviderInvatationStatus?RequestId=" + serviceRequestModel.Id + "&ProviderListingId=" + listingmodel.ProviderListingId + "&Status=true" + "'>Accept Invitation</a>"; //mail.Body += "<a style='margin-right: 3px; padding: 7px;background-color:red; color: white' href='" + root + "/Consumer/ProviderInvatationStatus?RequestId=" + serviceRequestModel.Id + "&ProviderListingId=" + listingmodel.ProviderListingId + "&Status=false" + "'>Cancel Invitation</a>"; //mail.Body += "<a style='margin-right: 3px; padding: 7px;background-color:blue; color: white' href='" + root + "/Consumer/ProviderInvatationStatus?RequestId=" + serviceRequestModel.Id + "&ProviderListingId=" + listingmodel.ProviderListingId + "&Status=true&alter=1" + "'>Alternative Offer</a></td></tr></table>"; //mail.BodyEncoding = System.Text.Encoding.UTF8; mail.IsBodyHtml = true; mail.Priority = MailPriority.High; SmtpClient client = new SmtpClient(); client.Credentials = new System.Net.NetworkCredential(ConfigurationManager.AppSettings["AdminEmail"], ConfigurationManager.AppSettings["Password"]); client.Port = 587; client.Host = "smtp.gmail.com"; client.EnableSsl = true; client.Send(mail); }
public virtual IActionResult ContactUsSend(ContactUsModel model, bool captchaValid) { //validate CAPTCHA if (_captchaSettings.Enabled && _captchaSettings.ShowOnContactUsPage && !captchaValid) { ModelState.AddModelError("", _localizationService.GetResource("Common.WrongCaptchaMessage")); } model = _commonModelFactory.PrepareContactUsModel(model, true); if (ModelState.IsValid) { var subject = _commonSettings.SubjectFieldOnContactUsForm ? model.Subject : null; var body = Core.Html.HtmlHelper.FormatText(model.Enquiry, false, true, false, false, false, false); _workflowMessageService.SendContactUsMessage(_workContext.WorkingLanguage.Id, model.Email.Trim(), model.FullName, subject, body); model.SuccessfullySent = true; model.Result = _localizationService.GetResource("ContactUs.YourEnquiryHasBeenSent"); //activity log _customerActivityService.InsertActivity("PublicStore.ContactUs", _localizationService.GetResource("ActivityLog.PublicStore.ContactUs")); return(View(model)); } return(View(model)); }
public JsonResult ContactUs(ContactUsModel message) { string resultMessage = null; bool SendingResult = MessagesController.ContactUS(message, out resultMessage); return(Json(new { Message = resultMessage }, JsonRequestBehavior.AllowGet)); }
public virtual async Task <IActionResult> ContactUsSend(ContactUsModel model, IFormCollection form, bool captchaValid) { //validate CAPTCHA if (_captchaSettings.Enabled && _captchaSettings.ShowOnContactUsPage && !captchaValid) { ModelState.AddModelError("", _captchaSettings.GetWrongCaptchaMessage(_localizationService)); } var result = await _mediator.Send(new ContactUsSendCommand() { CaptchaValid = captchaValid, Form = form, Model = model, Store = _storeContext.CurrentStore }); if (result.errors.Any()) { foreach (var item in result.errors) { ModelState.AddModelError("", item); } } else { model = result.model; return(View(model)); } model.DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnContactUsPage; return(View(model)); }
public ActionResult ContactUs(ContactUsModel model) { MailMessage mm = new MailMessage("*****@*****.**", model.EmaiId) { Subject = model.FirstName, Body = "Hello," + "<div>-----" + "<div>Subject: " + model.Subject + "<div>Cmment/Questions: " + model.comment + "<div><div>-----<div>Regards," + "<div>" + model.FirstName, IsBodyHtml = true }; SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; smtp.Port = 587; smtp.EnableSsl = true; smtp.UseDefaultCredentials = false; smtp.Credentials = new NetworkCredential("*****@*****.**", "Note@tatva"); smtp.Send(mm); projectEntities1 db = new projectEntities1(); comment c = new comment(); c.FullName = model.FirstName; c.EmailId = model.EmaiId; c.Comment1 = model.comment; c.Subject = model.Subject; db.comments.Add(c); db.SaveChanges(); TempData["Success"] = "Email sent Successfully Done!"; return(RedirectToAction("ContactUs", "Auth")); }
public ActionResult SendForm(ContactUsModel model, HttpPostedFileBase file) { var response = Request["g-recaptcha-response"]; if (model.ValidateCaptcha(response)) { if (model.SendMail(file)) { ViewBag.SendMail = true; ViewBag.ShowForm = false; ViewBag.Message = "Thank you for contacting us. We will get back to you soon."; model = new ContactUsModel(); } else { ViewBag.SendMail = false; ViewBag.ShowForm = false; ViewBag.Message = "Sorry! Email sending failed."; model = new ContactUsModel(); } } else { ViewBag.SendMail = false; ViewBag.ShowForm = false; ViewBag.Message = "Please enter Captcha field."; } model.Populate(TSMContext.CurrentPage, TSMContext.CurrentLanguageID); ViewBag.PageTitle = model.Page_Language.PageTitle; ViewBag.PageDescription = model.Page_Language.PageMetadata; ViewBag.PageKeywords = model.Page_Language.PageKeywords; return(View("~/Views/ContactUs/ContactUs.cshtml", model)); }
public void Should_not_have_error_when_fullName_is_specified() { var model = new ContactUsModel(); model.FullName = "John Smith"; _validator.ShouldNotHaveValidationErrorFor(x => x.FullName, model); }
public void Should_not_have_error_when_email_is_correct_format() { var model = new ContactUsModel(); model.Email = "*****@*****.**"; _validator.ShouldNotHaveValidationErrorFor(x => x.Email, model); }
public virtual async Task <ActionResult> Index(ContactUsModel model) { if (CurrentSettings.UseGoogleRecaptchaForContactUs) { ViewBag.publicKey = CurrentSettings.GoogleRecaptchaSiteKey; if (!ReCaptcha.Validate(CurrentSettings.GoogleRecaptchaSecretKey)) { ViewBag.RecaptchaLastErrors = ReCaptcha.GetLastErrors(HttpContext); return(View(model)); } } if (!ModelState.IsValid) { return(View(model)); } await _userMessagingService.AddAsync(new TblUserMessages() { Email = model.Email, Message = model.Message, Name = model.Name, ReceiveDate = DateTime.Now, Subject = model.Subject, UserId = WorkContext.CurrentUser?.Id }); SuccessNotification(_localizationService.GetResource("YourMessageHasBeenReceived")); return(RedirectToAction("Index")); }
public ActionResult ContactUsSend(ContactUsModel model, bool captchaValid) { //validate CAPTCHA if (_captchaSettings.Value.Enabled && _captchaSettings.Value.ShowOnContactUsPage && !captchaValid) { ModelState.AddModelError("", T("Common.WrongCaptcha")); } if (ModelState.IsValid) { string email = model.Email.Trim(); string fullName = model.FullName; string subject = T("ContactUs.EmailSubject", _services.StoreContext.CurrentStore.Name); var emailAccount = _emailAccountService.Value.GetDefaultEmailAccount(); string from = null; string fromName = null; string body = Core.Html.HtmlUtils.FormatText(model.Enquiry, false, true, false, false, false, false); //required for some SMTP servers if (_commonSettings.Value.UseSystemEmailForContactUsForm) { from = emailAccount.Email; fromName = emailAccount.DisplayName; body = string.Format("<strong>From</strong>: {0} - {1}<br /><br />{2}", Server.HtmlEncode(fullName), Server.HtmlEncode(email), body); } else { from = email; fromName = fullName; } _queuedEmailService.Value.InsertQueuedEmail(new QueuedEmail { From = from, FromName = fromName, To = emailAccount.Email, ToName = emailAccount.DisplayName, Priority = 5, Subject = subject, Body = body, CreatedOnUtc = DateTime.UtcNow, EmailAccountId = emailAccount.Id, ReplyTo = email, ReplyToName = fullName }); model.SuccessfullySent = true; model.Result = T("ContactUs.YourEnquiryHasBeenSent"); //activity log _services.CustomerActivity.InsertActivity("PublicStore.ContactUs", T("ActivityLog.PublicStore.ContactUs")); return(View(model)); } model.DisplayCaptcha = _captchaSettings.Value.Enabled && _captchaSettings.Value.ShowOnContactUsPage; return(View(model)); }
public async Task <bool> ContactUsEmail(ContactUsModel model) { if (!ModelState.IsValid) { return(false); } string htmlTemplatePath = Path.Combine(_hostingEnvironment.WebRootPath, FolderName.EMAIL_TEMPLATE_FOLDER, EmailTemplate.CONTACT_US_TEMPLATE); StringBuilder htmlBody; using (StreamReader reader = new StreamReader(htmlTemplatePath)) { htmlBody = new StringBuilder(reader.ReadToEnd()); } htmlBody.Replace(EmailParameter.NAME, model.Name); htmlBody.Replace(EmailParameter.PHONE, model.Phone); htmlBody.Replace(EmailParameter.EMAIL, model.Email); htmlBody.Replace(EmailParameter.SUBJECT, model.Subject); htmlBody.Replace(EmailParameter.COMMENTS, model.Comments); NotificationUtils <ContactUsController> notificationUtils = new NotificationUtils <ContactUsController>(_appSettings, _logger); string subject = string.Format(EmailSubject.CONTACT_US_Subject, model.Subject); notificationUtils.SendEmail(subject, htmlBody.ToString(), _appSettings.ToEmail, isBodyHtml: true); _logger.LogDebug("ContactUs email is being processed"); return(true); }
public virtual ActionResult ContactUs() { var model = new ContactUsModel(); model = _commonModelFactory.PrepareContactUsModel(model, false); return(View(model)); }
public ActionResult ContactUs(ContactUsModel obj) { if (ModelState.IsValid) { ContactUs cu = new ContactUs { FullName = obj.FullName, EmailId = obj.EmailId, Subject = obj.Subject, Question = obj.Question, CreatedDate = DateTime.Now, IsActive = false }; if (User.Identity.IsAuthenticated) { cu.IsActive = true; } objNotesEntities.ContactUs.Add(cu); objNotesEntities.SaveChanges(); } AccRelTemplate.ContactUsEmail.ContactUs(obj.Subject, obj.FullName, obj.Question); ModelState.Clear(); return(View()); }
// ************************************** // URL: /Home/Contact/ // ************************************** public virtual ActionResult Contact() { var model = new ContactUsModel() { Email = User.Identity.IsAuthenticated ? User.Identity.Name : "", Name = User.Identity.IsAuthenticated ? this.Friendly() : "", NavigationLocation = new string[] { "Contact" }, PageTitle = "Send us a question or comment:" }; model.ContactInfo = this.SiteProfile().GetContactInfo(Account.User()); return View(model); }
public virtual ActionResult Contact(ContactUsModel model) { if (ModelState.IsValid) { var vm = new ContactUsModel() { NavigationLocation = new string[] { "Contact" } }; vm.PageTitle = "Thanks for e-mailing us!"; vm.PageMessage = "Your e-mail has been successfully sent to our team, and we will review your message and respond as quickly as possible."; vm.ContactInfo = this.SiteProfile().GetContactInfo(Account.User()); string sender = String.Format("{0} <{1}>", this.SiteProfile().CompanyName, SystemConfig.AdminEmailAddress);// string subject = String.Format("[{0} Contact Us] {1}", this.SiteProfile().CompanyName, model.Subject); StringBuilder sb = new StringBuilder(); sb.AppendFormat("<p>Name: {0}</p>", model.Name); sb.AppendFormat("<p>Email: {0}</p>", model.Email); sb.AppendFormat("<p>Company: {0}</p>", model.Company); sb.AppendFormat("<p>Regarding: {0}</p>", model.Subject); sb.AppendFormat("<p>Comments:</p><p><pre>{0}</pre></p>", model.Body); string msg = sb.ToString(); sb = null; try { Mail.SendMail( sender, String.Concat(vm.ContactInfo.Email, ",", vm.ContactInfo.AdminEmail),//SiteProfileData.SiteProfile().ContactEmail,//Settings.ContactEmailAddress.Text(), subject, msg ); } catch (Exception ex) { Log.Error(ex); } return View(vm); } else { model.NavigationLocation = new string[] { "Contact" }; model.PageTitle = "Send us a question or comment:"; model.ContactInfo = this.SiteProfile().GetContactInfo(Account.User()); this.FeedbackError("There was an error with the contact request you sent..."); return View(model); } }
public ActionResult ContactUs() { var model = new ContactUsModel { Email = _workContext.CurrentCustomer.Email, FullName = _workContext.CurrentCustomer.GetFullName(), DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnContactUsPage }; return View(model); }
public ActionResult ContactUsSend(ContactUsModel 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 fullName = model.FullName; string subject = string.Format(_localizationService.GetResource("ContactUs.EmailSubject"), _storeContext.CurrentStore.GetLocalized(x => x.Name)); var emailAccount = _emailAccountService.GetEmailAccountById(_emailAccountSettings.DefaultEmailAccountId); if (emailAccount == null) emailAccount = _emailAccountService.GetAllEmailAccounts().FirstOrDefault(); if (emailAccount == null) throw new Exception("No email account could be loaded"); string from; string fromName; string body = Core.Html.HtmlHelper.FormatText(model.Enquiry, false, true, false, false, false, false); //required for some SMTP servers if (_commonSettings.UseSystemEmailForContactUsForm) { from = emailAccount.Email; fromName = emailAccount.DisplayName; body = string.Format("<strong>From</strong>: {0} - {1}<br /><br />{2}", Server.HtmlEncode(fullName), Server.HtmlEncode(email), body); } else { from = email; fromName = fullName; } _queuedEmailService.InsertQueuedEmail(new QueuedEmail { From = from, FromName = fromName, To = emailAccount.Email, ToName = emailAccount.DisplayName, ReplyTo = email, ReplyToName = fullName, Priority = QueuedEmailPriority.High, Subject = subject, Body = body, CreatedOnUtc = DateTime.UtcNow, EmailAccountId = emailAccount.Id }); model.SuccessfullySent = true; model.Result = _localizationService.GetResource("ContactUs.YourEnquiryHasBeenSent"); //activity log _customerActivityService.InsertActivity("PublicStore.ContactUs", _localizationService.GetResource("ActivityLog.PublicStore.ContactUs")); return View(model); } model.DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnContactUsPage; return View(model); }