public ActionResult contact(FormCollection frm) { string Current_Url = Request.UrlReferrer.PathAndQuery; string[] Path = Current_Url.Split('/'); string CandidateName = frm["name"].ToString(); string Mobilenumber = frm["phone"].ToString(); string EmailID = frm["email"].ToString(); string EnquiryMessage = frm["message"].ToString(); if (string.IsNullOrEmpty(CandidateName)) { TempData["qUERYmESSAGE"] = "Please fill the Name."; return(RedirectToAction(Path[2], Path[1])); } if (string.IsNullOrEmpty(EmailID)) { TempData["qUERYmESSAGE"] = "please fill the email"; return(RedirectToAction(Path[2], Path[1])); } if (string.IsNullOrEmpty(Mobilenumber)) { TempData["qUERYmESSAGE"] = "please fill the Mobile number"; return(RedirectToAction(Path[2], Path[1])); } if (string.IsNullOrEmpty(EnquiryMessage)) { TempData["qUERYmESSAGE"] = "please fill the Enquiry Message"; return(RedirectToAction(Path[2], Path[1])); } T_EnquiryMaster ObjNew = new T_EnquiryMaster(); ObjNew.Emailid = EmailID; ObjNew.MobileNo = Mobilenumber; ObjNew.Name = CandidateName; ObjNew.UserMessage = EnquiryMessage; ObjNew.RequestedURL = Current_Url; ObjNew.ModifiedBy = EmailID; ObjNew.CreateDate = DateTime.Now; ObjNew.ModifiedDate = DateTime.Now; ObjNew.Active = true; db.T_EnquiryMaster.Add(ObjNew); db.SaveChanges(); if (SendUserInfo(ObjNew)) { TempData["qUERYmESSAGE"] = " Dear " + ObjNew.Name + ", Your Enquiry Application has been Submitted. Thank you for INSTITUTE OF HOTEL MANAGEMENT & CATERING SCIENCE (IHMCS) Enquiry. We will get back to you soon!!!"; } return(RedirectToAction("thankyou")); }
public bool SendUserInfo(T_EnquiryMaster ObjNew) { if (string.IsNullOrEmpty(ObjNew.Name)) { ViewBag.Status = "Please Enter User Name."; } if (string.IsNullOrEmpty(ObjNew.Emailid)) { ViewBag.Status = "Please Enter Contact No."; } if (string.IsNullOrEmpty(ObjNew.MobileNo)) { ViewBag.Status = "Please Enter Email ID."; } if (string.IsNullOrEmpty(ObjNew.UserMessage)) { ViewBag.Status = "Please Enter Enquiry Message."; } try { MailMessage message = new MailMessage(); message.To.Add(ObjNew.Emailid); message.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure; message.From = new System.Net.Mail.MailAddress("*****@*****.**", "INSTITUTE OF HOTEL MANAGEMENT & CATERING SCIENCE (IHMCS) Enquiry Details"); message.Bcc.Add("*****@*****.**"); message.Subject = "INSTITUTE OF HOTEL MANAGEMENT & CATERING SCIENCE (IHMCS) Enquiry Details : " + ObjNew.Name; message.Body = "Hi " + ObjNew.Name + ", " + System.Environment.NewLine + System.Environment.NewLine + "======================================================================================== " + System.Environment.NewLine + " User Name : " + ObjNew.Name + System.Environment.NewLine + " Contact No : " + ObjNew.MobileNo + System.Environment.NewLine + " Email ID : " + ObjNew.Emailid + System.Environment.NewLine + " Dear " + ObjNew.Name + ", Your Enquiry Application has been Submitted. Thank you for INSTITUTE OF HOTEL MANAGEMENT & CATERING SCIENCE (IHMCS) Enquiry. We will get back to you soon!!!" + System.Environment.NewLine + " Enquiry Message: " + ObjNew.UserMessage + "." + System.Environment.NewLine + "Feel free to Visit INSTITUTE OF HOTEL MANAGEMENT & CATERING SCIENCE (IHMCS) Web Portal." + System.Environment.NewLine + " Enquiry Requested From : " + ObjNew.RequestedURL + System.Environment.NewLine + " ======================================================================================== " + System.Environment.NewLine + System.Environment.NewLine + System.Environment.NewLine + System.Environment.NewLine + "Thanks & Regards," + System.Environment.NewLine + "INSTITUTE OF HOTEL MANAGEMENT & CATERING SCIENCE (IHMCS)," + System.Environment.NewLine + "CORPORATE OFFICE :-" + System.Environment.NewLine + "D-1, Bareja Tower," + System.Environment.NewLine + "Main Mathura Road, Badarpur, New Delhi- 110044," + System.Environment.NewLine + "Phone :- 011-2989-2088" + System.Environment.NewLine + "Email ID :- [email protected]/[email protected]" + System.Environment.NewLine + "Contact No : +91-8285148778" + System.Environment.NewLine; //var contentType = new System.Net.Mime.ContentType(System.Net.Mime.MediaTypeNames.Application.Pdf); message.IsBodyHtml = false; SmtpClient client = new SmtpClient(); client.Host = "mail.ihmcsdelhi.org"; client.Port = 25; client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "b9Jzm?05"); client.Send(message); return(true); } catch (Exception ex) { ViewBag.Status = "Problem while sending email, Please check details." + ex.ToString(); } return(false); }