public ActionResult SendQuoteForm(FreeQuote quote, string Capcha) { var captchatext = Convert.ToString(Session["captchaText"]); var captchatexts = Regex.Replace(captchatext, @"\s+", ""); if (quote.Email != null && Capcha != null && quote.fullname != null) { if (captchatext == Capcha) { SendEmailToUser(quote); // SendEmail(quote); return(Json(1, JsonRequestBehavior.AllowGet)); } else { return(Json("Captcha text is not validated, please try again.", JsonRequestBehavior.AllowGet)); } } else { return(Json(" * fields are required", JsonRequestBehavior.AllowGet)); } }
public string SendEmailToUser(FreeQuote quote) { string result = ""; var qFullName = quote.fullname.Trim(); var qEmail = quote.Email.Trim(); if (qFullName != "" && qEmail != "") { string to = "*****@*****.**"; string from = qEmail; string body = @"<html><title></title> <head> <style> body { background: none; } table td { height: 30%; width: 50%; border-color: #13A0B2; } table th { height: 70%; width: 50%; background-color: #13A0B2; color: white; font-size: 100%; } </style> </head> <body> <div><table border=""1"" style='width:100%;'> <thead> <tr style='background:#13A0B2;'> <th colspan=""2"" style='height: 70%; width: 50%; background-color: #13A0B2; color: white; font-size: 100%;'>CLIENT INFORMATION</th> </tr> </thead> <tbody> <tr> <td style='height: 100%; ;width: 50%; color:black; border-color: #13A0B2;'>Full Name:</td> <td style='height: 100%;width: 50%; color:black; border-color: #13A0B2;'> " + quote.fullname + @"</td> </tr> <tr> <td style='height: 30%;width: 50%; color:black; border-color: #13A0B2;'>Phone:</td> <td style='height: 30%;width: 50%; color:black; border-color: #13A0B2;'> " + quote.CellNo + @"</td> </tr> <tr> <td style='height: 30%;width: 50%; color:black; border-color: #13A0B2;'>Email:</td> <td style='height: 30%;width: 50%; color:black; border-color: #13A0B2;'> " + quote.Email + @"</td> </tr> </tbody> </table > <table border=""1"" style='width:100%;'> <tbody> <thead> <tr style='background:#13A0B2;'> <th colspan='2' style='height: 70%; width: 100%; background-color: #13A0B2; color: white;font-size: 100%;' >OFFENCE/TICKET INFORMATION</th> </tr> </thead> <tr> <td style=' height: 30%;width: 50%; color:black; border-color: #13A0B2;'>Type of Summons/Offence 1:</td> <td style=' height: 30%;width: 50%; color:black; border-color: #13A0B2;'> " + quote.offences1 + @"</td> </tr> <tr> <td style='height: 30%;width: 50%; color:black; border-color: #13A0B2;'>Type of Summons/Offence 2: </td> <td style='height: 30%;width: 50%; color:black; border-color: #13A0B2;'> " + quote.offences2 + @"</td> </tr> <tr> <td style=' height: 30%;width: 50%; color:black; border-color: #13A0B2;'>Type of Summons/Offence 3: </td> <td style=' height: 30%;width: 50%; color:black; border-color: #13A0B2;'> " + quote.offences3 + @"</td> </tr> </tbody> </table > <table border=""1"" style='width:100%;'> <tbody> <tr> <td style=' height: 30%;width: 50%; color:black; border-color: #13A0B2;'>Or type your violation:</td> <td style=' height: 30%;width: 50%; color:black; border-color: #13A0B2;'> " + quote.violation + @"</td> </tr> <tr> <td style=' height: 30%;width: 50%; color:black; border-color: #13A0B2;'>Current Number of Points on License:</td> <td style=' height: 30%;width: 50%; color:black; border-color: #13A0B2;'> " + quote.pointno + @"</td> </tr> <tr> <td style=' height: 30%;width: 50%; color:black; border-color: #13A0B2;'>DWI or DUI:</td> <td style=' height: 30%;width: 50%; color:black; border-color: #13A0B2;'> " + quote.ddldwi + @"</td> </tr> </tbody> </table> <table border=""1"" style='width:100%;'> <tbody> <tr> <td style=' height: 30%;width: 50%; color:black; border-color: #13A0B2;'>Ticket Number:</td> <td style=' height: 30%;width: 50%; color:black; border-color: #13A0B2;'> " + quote.ticketnumber + @"</td> </tr> <tr> <td style=' height: 30%;width: 50%; color:black; border-color: #13A0B2;'>Date Ticket Was Issued:</td> <td style=' height: 30%;width: 50%; color:black; border-color: #13A0B2;'> " + quote.dateissue + @"</td> </tr> <tr> <td style=' height: 30%;width: 50%; color:black; border-color: #13A0B2;'>Court Location:</td> <td style=' height: 30%;width: 50%; color:black; border-color: #13A0B2;'> " + quote.location + @"</td> </tr> </tbody> </table> <table border=""1"" style='width:100%;'> <tbody> <tr> <td style=' height: 30%;width: 50%; color:black; border-color: #13A0B2;'>State of Your License </td> <td style=' height: 30%;width: 50%; color:black; border-color: #13A0B2;'> " + quote.state + @"</td> </tr> <tr> <td style=' height: 30%;width: 50%; color:black; border-color: #13A0B2;'>Have you used any plea bargains in the last 5 years?</td> <td style=' height: 30%;width: 50%; border-color: #13A0B2;'> " + quote.five + @"</td> </tr> <tr> <td style=' height: 30%;width: 50%;color:black;width: 50%; border-color: #13A0B2;'>Was the ticket a result of an accident? </td> <td style=' height: 30%;width: 50%; color:black;width: 50%; border-color: #13A0B2;'> " + quote.Accident + @"</td> </tr> </tbody> </table> <table border=""1"" style='width:100%;'> <tbody> <tr> <td style=' height: 30%;width: 50%; color:black; border-color: #13A0B2;'>If DUI and DWI: Have you had any other offences? </td> <td style=' height: 30%;width: 50%; color:black; border-color: #13A0B2;'> " + quote.HadOtherOffence + @"</td> </tr> <tr> <td style=' height: 30%;width: 50%; color:black; border-color: #13A0B2;'>Comments: </td> <td style=' height: 30%;width: 50%; color:black; border-color: #13A0B2;'> " + quote.Message + @"</td> </tr> </tbody> </table> </div> </body> <html> "; MailMessage mail = new MailMessage(from, to); SmtpClient client = new SmtpClient(); client.DeliveryMethod = SmtpDeliveryMethod.Network; client.UseDefaultCredentials = false; client.Host = "mail.newjerseydefensivedriving.net"; mail.Subject = "newjerseytraffictickets.com has sent you another lead! - From free quote form"; mail.IsBodyHtml = true; mail.Body = body; try { client.Send(mail); result = "Email Sent"; } catch (Exception ex) { result = ex.Message + "....... Inner exception is: " + ex.InnerException; } return(result); } else { return("All * fields are required."); } }
public ActionResult SendEmail(FreeQuote quote) { if (quote.fullname.Trim() != "" && quote.Email.Trim() != "") { string result = ""; var message = new MailMessage(); message.To.Add(new MailAddress("*****@*****.**")); message.From = new MailAddress("*****@*****.**"); message.CC.Add("*****@*****.**"); // message.CC.Add("*****@*****.**"); // message.CC.Add("*****@*****.**"); // message.CC.Add("*****@*****.**"); message.Subject = "newjerseytraffictickets.com has sent you another lead! - From free quote form"; string body = @" <html> <title> </title> <head> <style> body { background: none; } table td { height: 30%; width: 50%; border-color: #13A0B2; } table th { height: 70%; width: 50%; background-color: #13A0B2; color: white; font-size: 100%; } </style> </head> <body> <div><table border=""1"" style='width:100%;'> <thead> <tr style='background:#13A0B2;'> <th colspan=""2"" style='height: 70%; width: 50%; background-color: #13A0B2; color: white; font-size: 100%;'>CLIENT INFORMATION</th> </tr> </thead> <tbody> <tr> <td style='height: 100%; ;width: 50%; color:black; border-color: #13A0B2;'>Full Name:</td> <td style='height: 100%;width: 50%; color:black; border-color: #13A0B2;'> " + quote.fullname + @"</td> </tr> <tr> <td style='height: 30%;width: 50%; color:black; border-color: #13A0B2;'>Phone:</td> <td style='height: 30%;width: 50%; color:black; border-color: #13A0B2;'> " + quote.CellNo + @"</td> </tr> <tr> <td style='height: 30%;width: 50%; color:black; border-color: #13A0B2;'>Email:</td> <td style='height: 30%;width: 50%; color:black; border-color: #13A0B2;'> " + quote.Email + @"</td> </tr> </tbody> </table > <table border=""1"" style='width:100%;'> <tbody> <thead> <tr style='background:#13A0B2;'> <th colspan='2' style='height: 70%; width: 100%; background-color: #13A0B2; color: white;font-size: 100%;' >OFFENCE/TICKET INFORMATION</th> </tr> </thead> <tr> <td style=' height: 30%;width: 50%; color:black; border-color: #13A0B2;'>Type of Summons/Offence 1:</td> <td style=' height: 30%;width: 50%; color:black; border-color: #13A0B2;'> " + quote.offences1 + @"</td> </tr> <tr> <td style='height: 30%;width: 50%; color:black; border-color: #13A0B2;'>Type of Summons/Offence 2: </td> <td style='height: 30%;width: 50%; color:black; border-color: #13A0B2;'> " + quote.offences2 + @"</td> </tr> <tr> <td style=' height: 30%;width: 50%; color:black; border-color: #13A0B2;'>Type of Summons/Offence 3: </td> <td style=' height: 30%;width: 50%; color:black; border-color: #13A0B2;'> " + quote.offences3 + @"</td> </tr> </tbody> </table > <table border=""1"" style='width:100%;'> <tbody> <tr> <td style=' height: 30%;width: 50%; color:black; border-color: #13A0B2;'>Or type your violation:</td> <td style=' height: 30%;width: 50%; color:black; border-color: #13A0B2;'> " + quote.violation + @"</td> </tr> <tr> <td style=' height: 30%;width: 50%; color:black; border-color: #13A0B2;'>Current Number of Points on License:</td> <td style=' height: 30%;width: 50%; color:black; border-color: #13A0B2;'> " + quote.pointno + @"</td> </tr> <tr> <td style=' height: 30%;width: 50%; color:black; border-color: #13A0B2;'>DWI or DUI:</td> <td style=' height: 30%;width: 50%; color:black; border-color: #13A0B2;'> " + quote.ddldwi + @"</td> </tr> </tbody> </table> <table border=""1"" style='width:100%;'> <tbody> <tr> <td style=' height: 30%;width: 50%; color:black; border-color: #13A0B2;'>Ticket Number:</td> <td style=' height: 30%;width: 50%; color:black; border-color: #13A0B2;'> " + quote.ticketnumber + @"</td> </tr> <tr> <td style=' height: 30%;width: 50%; color:black; border-color: #13A0B2;'>Date Ticket Was Issued:</td> <td style=' height: 30%;width: 50%; color:black; border-color: #13A0B2;'> " + quote.dateissue + @"</td> </tr> <tr> <td style=' height: 30%;width: 50%; color:black; border-color: #13A0B2;'>Court Location:</td> <td style=' height: 30%;width: 50%; color:black; border-color: #13A0B2;'> " + quote.location + @"</td> </tr> </tbody> </table> <table border=""1"" style='width:100%;'> <tbody> <tr> <td style=' height: 30%;width: 50%; color:black; border-color: #13A0B2;'>State of Your License </td> <td style=' height: 30%;width: 50%; color:black; border-color: #13A0B2;'> " + quote.state + @"</td> </tr> <tr> <td style=' height: 30%;width: 50%; color:black; border-color: #13A0B2;'>Have you used any plea bargains in the last 5 years?</td> <td style=' height: 30%;width: 50%; border-color: #13A0B2;'> " + quote.five + @"</td> </tr> <tr> <td style=' height: 30%;width: 50%;color:black;width: 50%; border-color: #13A0B2;'>Was the ticket a result of an accident? </td> <td style=' height: 30%;width: 50%; color:black;width: 50%; border-color: #13A0B2;'> " + quote.Accident + @"</td> </tr> </tbody> </table> <table border=""1"" style='width:100%;'> <tbody> <tr> <td style=' height: 30%;width: 50%; color:black; border-color: #13A0B2;'>If DUI and DWI: Have you had any other offences? </td> <td style=' height: 30%;width: 50%; color:black; border-color: #13A0B2;'> " + quote.HadOtherOffence + @"</td> </tr> <tr> <td style=' height: 30%;width: 50%; color:black; border-color: #13A0B2;'>Comments: </td> <td style=' height: 30%;width: 50%; color:black; border-color: #13A0B2;'> " + quote.Message + @"</td> </tr> </tbody> </table> </div> </body> <html> "; message.IsBodyHtml = true; message.Body = body; 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; try { smtp.Send(message); result = "Email Sent"; } catch (Exception ex) { result = ex.Message + "....... Inner exception is: " + ex.InnerException; } } return(Json(result, JsonRequestBehavior.AllowGet)); } else { return(Json("All Star Fileds are Requried", JsonRequestBehavior.AllowGet)); } }