public ActionResult List(string param1) { string PageId = Request.Params["page"]; string xml = Dm.GetListXml(param1, PageId); List<Post> posts = Dm.ParseList(xml); Category category = Dm.ParseCategory(xml); category.Name = param1; if (Request.HttpMethod.ToLower() == "post") { JsonMessage jm = new JsonMessage(); if (posts.Count > 0){ jm.Result = true; jm.Object = posts; } else { jm.Result = false; } return Json(jm); } else { ViewData["Posts"] = posts; ViewData["Category"] = category; if (param1.ToLower() == "news") { return View("ListNews"); } else if (param1.ToLower() == "vacancies") { return View("ListVacancies"); } else if (param1.ToLower() == "feedback") { return View("ListFeedback"); } return View(); } }
public ActionResult FeedbackRequest(FormCollection collection) { JsonMessage jm = new JsonMessage(); try { string name = collection["name"]; string message = collection["message"]; string body = "Имя: " + name + "\n"; body += "Сообщение: " + message + "\n"; string subject = "Отзыв c сайта natpotolki"; if (Convert.ToBoolean(ConfigurationManager.AppSettings["UseAgavaMail"])) { MailMessage mailObj = new MailMessage(); mailObj.From = new MailAddress(ConfigurationManager.AppSettings["messageFrom"]); mailObj.To.Add(ConfigurationManager.AppSettings["messageTo"]); mailObj.Subject = subject; mailObj.Body = body; SmtpClient SMTPServer = new SmtpClient("localhost"); SMTPServer.Send(mailObj); } else { System.Web.Mail.MailMessage mail = new System.Web.Mail.MailMessage(); string SMTP_SERVER = "http://schemas.microsoft.com/cdo/configuration/smtpserver"; string SMTP_SERVER_PORT = "http://schemas.microsoft.com/cdo/configuration/smtpserverport"; string SEND_USING = "http://schemas.microsoft.com/cdo/configuration/sendusing"; string SMTP_USE_SSL = "http://schemas.microsoft.com/cdo/configuration/smtpusessl"; string SMTP_AUTHENTICATE = "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"; string SEND_USERNAME = "******"; string SEND_PASSWORD = "******"; mail.Fields[SMTP_SERVER] = ConfigurationManager.AppSettings["SMTP"]; mail.Fields[SMTP_SERVER_PORT] = 465; mail.Fields[SEND_USING] = 2; mail.Fields[SMTP_USE_SSL] = true; mail.Fields[SMTP_AUTHENTICATE] = 1; mail.Fields[SEND_USERNAME] = ConfigurationManager.AppSettings["SMTP_login"]; mail.Fields[SEND_PASSWORD] = ConfigurationManager.AppSettings["SMTP_password"]; mail.From = ConfigurationManager.AppSettings["messageFrom"]; mail.To = ConfigurationManager.AppSettings["messageTo"]; mail.Subject = "Отзыв c сайта natpotolki"; mail.BodyFormat = System.Web.Mail.MailFormat.Text; mail.Body += "Имя: " + name + "\n"; mail.Body += "Сообщение: " + message + "\n"; System.Web.Mail.SmtpMail.SmtpServer = ConfigurationManager.AppSettings["SMTP"] + ":465"; System.Web.Mail.SmtpMail.Send(mail); } jm.Result = true; jm.Message = "Мы получили Ваш отзыв и опубликуем его после проверки..."; } catch (Exception e) { jm.Result = true; jm.Message = "Во время отправки произошла ошибка - " + e.ToString(); } return Json(jm); }
public ActionResult MeasurementRequest(FormCollection collection) { JsonMessage jm = new JsonMessage(); try { string name = collection["name"]; string phone = collection["phone"]; string email = collection["email"]; string body = "Имя: " + name + "\n"; body += "Телефон: " + phone + "\n"; body += "Email: " + email + "\n"; string subject = "Запись на замер c сайта natpotolki"; if (Convert.ToBoolean(ConfigurationManager.AppSettings["UseAgavaMail"])) { //1 MailMessage mailObj = new MailMessage(); mailObj.From = new MailAddress(ConfigurationManager.AppSettings["messageFrom"]); mailObj.To.Add(ConfigurationManager.AppSettings["messageTo"]); mailObj.Subject = subject; mailObj.Body = body; SmtpClient SMTPServer = new SmtpClient("localhost"); SMTPServer.Send(mailObj); //2 if (!String.IsNullOrWhiteSpace(email)) { MailMessage mailObj2 = new MailMessage(); mailObj2.From = new MailAddress(ConfigurationManager.AppSettings["messageFrom"]); mailObj2.To.Add(email); mailObj2.Subject = "Облако. Благодарим Вас за обращение в нашу компанию"; string filename = Server.MapPath("/Content/templates/mail.htm"); if (System.IO.File.Exists(filename)) { using (StreamReader sr = new StreamReader(filename)) { mailObj2.Body = sr.ReadToEnd(); }; mailObj2.IsBodyHtml = true; SMTPServer.Send(mailObj2); } } } else { System.Web.Mail.MailMessage mail = new System.Web.Mail.MailMessage(); string SMTP_SERVER = "http://schemas.microsoft.com/cdo/configuration/smtpserver"; string SMTP_SERVER_PORT = "http://schemas.microsoft.com/cdo/configuration/smtpserverport"; string SEND_USING = "http://schemas.microsoft.com/cdo/configuration/sendusing"; string SMTP_USE_SSL = "http://schemas.microsoft.com/cdo/configuration/smtpusessl"; string SMTP_AUTHENTICATE = "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"; string SEND_USERNAME = "******"; string SEND_PASSWORD = "******"; mail.Fields[SMTP_SERVER] = ConfigurationManager.AppSettings["SMTP"]; mail.Fields[SMTP_SERVER_PORT] = 465; mail.Fields[SEND_USING] = 2; mail.Fields[SMTP_USE_SSL] = true; mail.Fields[SMTP_AUTHENTICATE] = 1; mail.Fields[SEND_USERNAME] = ConfigurationManager.AppSettings["SMTP_login"]; mail.Fields[SEND_PASSWORD] = ConfigurationManager.AppSettings["SMTP_password"]; mail.From = ConfigurationManager.AppSettings["messageFrom"]; mail.To = ConfigurationManager.AppSettings["messageTo"]; mail.Subject = subject; mail.BodyFormat = System.Web.Mail.MailFormat.Text; mail.Body += body; System.Web.Mail.SmtpMail.SmtpServer = ConfigurationManager.AppSettings["SMTP"] + ":465"; System.Web.Mail.SmtpMail.Send(mail); } jm.Result = true; jm.Message = "Мы получили Ваш запрос и скоро свяжемся с Вами..."; } catch (Exception e) { jm.Result = true; jm.Message = "Во время отправки произошла ошибка - " + e.ToString(); } return Json(jm); }