public void SendMail(string clName, string clEmail, string clDestinationCity, string consultName, string QuoteNumber) { try { DataSet ds = leadBl.GetMailInfo(); if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { string SmtpServer = ds.Tables[0].Rows[0]["con_smtp_host"].ToString(); int SmtpPort = Convert.ToInt32(ds.Tables[0].Rows[0]["con_smtp_port"].ToString()); //int SmtpPort = 587; string MailFrom = ds.Tables[0].Rows[0]["con_mail_from"].ToString(); string DisplayNameFrom = ds.Tables[0].Rows[0]["con_from_name"].ToString(); string FromPassword = ds.Tables[0].Rows[0]["con_from_pwd"].ToString(); string MailTo = clEmail; //string MailTo = "*****@*****.**"; string DisplayNameTo = string.Empty; string MailCc = string.Empty; string DisplayNameCc = string.Empty; string MailBcc = string.Empty; string Subject = string.Empty; string MailText = string.Empty; string Attachment = string.Empty; string cusAttachment = string.Empty; string filepath = Server.MapPath("~/ConvertToBookPDF"); string FileName = filepath + "\\" + QuoteNumber + ".pdf"; if (File.Exists(FileName)) { Attachment = FileName; } try { Subject = "Serendipity Travel >> Booking confirmation for " + clName + " to " + clDestinationCity; MailCc = ""; MailText = "Dear " + clName + ", <br/><br/>"; MailText += "Please find attached your confirmation for your holiday to <b>" + clDestinationCity + "</b>. <br/><br/>"; MailText += "Should full payment not be received within 24 hours of receiving this confirmation, the cost will be subject to a recalculation due to the volatile rate of exchange. Air tickets have to be issued either same day or within 24 hours of receiving the confirmation.<br/><br/>"; MailText += "Due to the volatility of the Rand (ZAR), please call us prior to making full payment on any bookings.<br/>"; MailText += "Cancellation fees apply should booking be cancelled or for no show.<br/>"; MailText += "Once full payment has been received, I will advise you, when you can expect your travel vouchers.<br/>"; MailText += "Thank you for booking with Serendipity Travel.<br/>"; MailText += "Kind regards, <br/><br/>"; MailText += "(" + consultName + ")"; MailText += "<div style='float:left; width:10%; border-right:3px solid #03F; padding:0 20px; margin-right:50px;'><img style='width:100%; display:block;' src='http://tcrm.askswg.co.za/images/logoEmail.png' /></div><div><h1 style='color:#3fa9df; margin:0 0 5px; font-size:12px;'>" + Session["Name"].ToString() + "</h1><h3 style='color:#25377b; margin:0 0 5px; font-size:12px; font-weight:400;'>Travel Consultant</h3><h5 style='color:#25377b; margin:0 0 5px; font-size:12px; font-weight:400;'>+27 31 2010 630 <span style='color:#3fa9df;'>|</span>" + Session["ConsultantEmail"].ToString() + "</h5><p style='color:#25377b; margin:0 0 0px; font-size:12px; font-weight:400;margin-left:165px;'><a href='#'><img src='http://tcrm.askswg.co.za/images/facebook.png' style='width:3%' /></a> <a href='#'><img src='http://tcrm.askswg.co.za/images/twitter.png' style='width:3%' /></a> <a href='#'><img src='http://tcrm.askswg.co.za/images/linkedin.png' style='width:3%' /></a> Suite 3, 2nd floor Silver Oaks, 36 Silverton Road, Musgruve, Durban</p></div>"; bool mailSent = UpdateCustomMail(SmtpServer, SmtpPort, MailFrom, DisplayNameFrom, FromPassword, MailTo, DisplayNameTo, MailCc, "", "", "", DisplayNameCc, MailBcc, Subject, MailText, Attachment); if (mailSent) { MailSentSatatus(QuoteNumber); CommanClass.MailStatusLog(LeadID, "BT001", "Success", "", QuoteNumber); Response.Redirect("EditLead.aspx?t=quote&idq=" + LeadID); } else { CommanClass.MailStatusLog(LeadID, "BT001", "Fail", "", QuoteNumber); lblMessage.Text = "Something went wrong. Please contact administrator!"; lblMessage.ForeColor = System.Drawing.Color.Red; } } catch { } } } catch { } }
public void SendMail(string clEmail, string strCC, string srtSubject, string strText, int Type) { try { DataSet ds = leadBL.GetMailInfo(); if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { string SmtpServer = ds.Tables[0].Rows[0]["con_smtp_host"].ToString(); int SmtpPort = Convert.ToInt32(ds.Tables[0].Rows[0]["con_smtp_port"].ToString()); //int SmtpPort = 587; string MailFrom = ds.Tables[0].Rows[0]["con_mail_from"].ToString(); string DisplayNameFrom = ds.Tables[0].Rows[0]["con_from_name"].ToString(); string FromPassword = ds.Tables[0].Rows[0]["con_from_pwd"].ToString(); string MailTo = clEmail; //string MailTo = "*****@*****.**"; string DisplayNameTo = string.Empty; string MailCc = string.Empty; string DisplayNameCc = string.Empty; string MailBcc = string.Empty; string Subject = string.Empty; string MailText = string.Empty; string Attachment = string.Empty; try { Subject = srtSubject; MailCc = !string.IsNullOrEmpty(strCC) ? strCC : ""; MailText = strText; //if (Type == 1) //{ // MailText = "<p><strong>Dear Valued Client,</strong></p>"; // MailText += "<p>Thanks for submitting a travel request through to Serendipity Travel.</p>"; // MailText += "<p>I trust that our consultant has reverted to you with a suitable quotation specifict to your travel needs. Should you not have received a response, please do let us know.</p>"; // MailText += "<p>Please advise if we can assist you further by tailor making a suitable package for you should the package sent through not be suitable enough.</p>"; // MailText += "<p><strong>Kind regards</strong></p>"; // MailText += "<div style='float:left; width:10%; border-right:3px solid #03F; padding:0 20px; margin-right:50px;'><img style='width:100%; display:block;' src='http://tcrm.askswg.co.za/images/logoEmail.png' /></div><div><h1 style='color:#3fa9df; margin:0 0 5px; font-size:12px;'>" + Session["Name"].ToString() + "</h1><h3 style='color:#25377b; margin:0 0 5px; font-size:12px; font-weight:400;'>Travel Consultant</h3><h5 style='color:#25377b; margin:0 0 5px; font-size:12px; font-weight:400;'>+27 31 2010 630 <span style='color:#3fa9df;'>|</span>" + Session["ConsultantEmail"].ToString() + "</h5><p style='color:#25377b; margin:0 0 0px; font-size:12px; font-weight:400;margin-left:165px;'><a href='#'><img src='http://tcrm.askswg.co.za/images/facebook.png' style='width:3%' /></a> <a href='#'><img src='http://tcrm.askswg.co.za/images/twitter.png' style='width:3%' /></a> <a href='#'><img src='http://tcrm.askswg.co.za/images/linkedin.png' style='width:3%' /></a> Suite 3, 2nd floor Silver Oaks, 36 Silverton Road, Musgruve, Durban</p></div>"; //} //else //{ // MailText = "<p><strong>Dear ,</strong></p>" + lblLName.Text; // MailText += "<p>Thank you so much for your enquiry I received today. In order to quote you accurately, I require the following additional information.</p>"; // MailText += "<p>1. Dates of travel</p>"; // MailText += "<p>2. Destination</p>"; // MailText += "<p>3. Where will you be travelling from ie. Joburg, Durban or Cape Town</p>"; // MailText += "<p>4. Estimated budget</p>"; // MailText += "<p>5. How many people will be travelling incl. children (and their ages)</p>"; // MailText += "<p>6. Are you travelling for a special occation ie. birthday, anniversary, honeymoon etc.</p>"; // MailText += "<p>As soon as I receive the above information, I can work on some options for you.</p>"; // MailText += "<p><strong>Kind regards</strong></p>"; // MailText += "<div style='float:left; width:10%; border-right:3px solid #03F; padding:0 20px; margin-right:50px;'><img style='width:100%; display:block;' src='http://tcrm.askswg.co.za/images/logoEmail.png' /></div><div><h1 style='color:#3fa9df; margin:0 0 5px; font-size:12px;'>" + Session["Name"].ToString() + "</h1><h3 style='color:#25377b; margin:0 0 5px; font-size:12px; font-weight:400;'>Travel Consultant</h3><h5 style='color:#25377b; margin:0 0 5px; font-size:12px; font-weight:400;'>+27 31 2010 630 <span style='color:#3fa9df;'>|</span>" + Session["ConsultantEmail"].ToString() + "</h5><p style='color:#25377b; margin:0 0 0px; font-size:12px; font-weight:400;margin-left:165px;'><a href='#'><img src='http://tcrm.askswg.co.za/images/facebook.png' style='width:3%' /></a> <a href='#'><img src='http://tcrm.askswg.co.za/images/twitter.png' style='width:3%' /></a> <a href='#'><img src='http://tcrm.askswg.co.za/images/linkedin.png' style='width:3%' /></a> Suite 3, 2nd floor Silver Oaks, 36 Silverton Road, Musgruve, Durban</p></div>"; //} bool mailSent = CommanClass.UpdateMail(SmtpServer, SmtpPort, MailFrom, DisplayNameFrom, FromPassword, MailTo, DisplayNameTo, MailCc, "", "", "", DisplayNameCc, MailBcc, Subject, MailText, Attachment); if (mailSent) { lblMessage.Text = "Email sent successfully."; lblMessage.ForeColor = System.Drawing.Color.Green; if (Type == 1) { CommanClass.MailStatusLog(Convert.ToInt32(Session["lsID"].ToString()), "FP001", "Success", "", ""); } else { CommanClass.MailStatusLog(Convert.ToInt32(Session["lsID"].ToString()), "MI001", "Success", "", ""); } DataSet dsInfo = leadBL.GetLeadInfo(Convert.ToInt32(Session["lsID"].ToString())); DataTable dtLeadHistory = dsInfo.Tables[1]; // Lead History LeadHistory(dtLeadHistory); } else { lblMessage.Text = "Email not sent."; lblMessage.ForeColor = System.Drawing.Color.Red; if (Type == 1) { CommanClass.MailStatusLog(Convert.ToInt32(Session["lsID"].ToString()), "FP001", "Fail", "", ""); } else { CommanClass.MailStatusLog(Convert.ToInt32(Session["lsID"].ToString()), "MI001", "Fail", "", ""); } DataSet dsInfo = leadBL.GetLeadInfo(Convert.ToInt32(Session["lsID"].ToString())); DataTable dtLeadHistory = dsInfo.Tables[1]; // Lead History LeadHistory(dtLeadHistory); } } catch (Exception ex) { lblMessage.Text = "Email not sent."; lblMessage.ForeColor = System.Drawing.Color.Red; CommanClass.MailStatusLog(Convert.ToInt32(Session["lsID"].ToString()), "MI001", "Fail", ex.Message, ""); DataSet dsInfo = leadBL.GetLeadInfo(Convert.ToInt32(Session["lsID"].ToString())); DataTable dtLeadHistory = dsInfo.Tables[1]; // Lead Hostory LeadHistory(dtLeadHistory); } } } catch { } }