Пример #1
0
        public ActionResult TourEnquiry(Enquiry model)
        {
            if (ModelState.IsValid)
            {
                string body = GenerateEmailBody(model);
                using (SmtpClient smtpClient = new SmtpClient())
                {
                    MailMessage msg = new MailMessage();
                    msg.To.Add(new MailAddress(WebSettings.AdminEmail));
                    msg.Body = body;
                    msg.IsBodyHtml = true;
                    msg.Subject = "Tour Guide Enquiry";
                    smtpClient.Send(msg);

                    return Json(new { statusCode = 200 }, JsonRequestBehavior.AllowGet);
                }
            }
            return PartialView("_TourEnquiryForm", model);
        }
Пример #2
0
 private string GenerateEmailBody(Enquiry model)
 {
     StringBuilder sb = new StringBuilder();
     sb.AppendLine("Tour Name:");
     sb.Append(model.TourName);
     sb.AppendLine();
     sb.AppendLine(" Name:");
     sb.Append(model.EnquirerName);
     sb.AppendLine();
     sb.AppendLine("Email:");
     sb.Append(model.Email);
     sb.AppendLine();
     sb.AppendLine("Message:");
     sb.Append(model.Message);
     return sb.ToString();
 }