private void SentNotification(Business.Service.ServiceBook objServiceBook, DataTable dtTonnerRequest) { //Checking whether low tonner request, if yes then send notification mail using (DataSet ds = objServiceBook.Service_Tonner_GetByTonnerRequestId(TonnerRequestId)) { string A3BWCurrentMeterReading = "", A3CLCurrentMeterReading = "", A4CLCurrentMeterReading = "", A4BWCurrentMeterReading = "", A3BWLastMeterReading = "", A3CLLastMeterReading = "", A4CLLastMeterReading = "", A4BWLastMeterReading = "", TonnerName = "", Yield = "", TonnerRequestNo = ""; if (ds != null) { TonnerRequestNo = dtTonnerRequest.Rows[0]["TonnerRequestNo"].ToString(); TonnerName = (ds.Tables[0].Rows[0]["SpareName"] == DBNull.Value) ? "" : ds.Tables[0].Rows[0]["SpareName"].ToString(); Yield = (ds.Tables[0].Rows[0]["Yield"] == DBNull.Value) ? "" : ds.Tables[0].Rows[0]["Yield"].ToString(); A3BWCurrentMeterReading = (ds.Tables[0].Rows[0]["A3BWCurrentMeterReading"] == DBNull.Value) ? "0" : ds.Tables[0].Rows[0]["A3BWCurrentMeterReading"].ToString(); A3CLCurrentMeterReading = (ds.Tables[0].Rows[0]["A3CLCurrentMeterReading"] == DBNull.Value) ? "0" : ds.Tables[0].Rows[0]["A3CLCurrentMeterReading"].ToString(); A4CLCurrentMeterReading = (ds.Tables[0].Rows[0]["A4CLCurrentMeterReading"] == DBNull.Value) ? "0" : ds.Tables[0].Rows[0]["A4CLCurrentMeterReading"].ToString(); A4BWCurrentMeterReading = (ds.Tables[0].Rows[0]["A4BWCurrentMeterReading"] == DBNull.Value) ? "0" : ds.Tables[0].Rows[0]["A4BWCurrentMeterReading"].ToString(); A3BWLastMeterReading = (ds.Tables[1].Rows.Count == 0 || ds.Tables[1].Rows[0]["A3BWLastMeterReading"] == DBNull.Value) ? "0" : ds.Tables[1].Rows[0]["A3BWLastMeterReading"].ToString(); A4BWLastMeterReading = (ds.Tables[1].Rows.Count == 0 || ds.Tables[1].Rows[0]["A4BWLastMeterReading"] == DBNull.Value) ? "0" : ds.Tables[1].Rows[0]["A4BWLastMeterReading"].ToString(); A3CLLastMeterReading = (ds.Tables[1].Rows.Count == 0 || ds.Tables[1].Rows[0]["A3CLLastMeterReading"] == DBNull.Value) ? "0" : ds.Tables[1].Rows[0]["A3CLLastMeterReading"].ToString(); A4CLLastMeterReading = (ds.Tables[1].Rows.Count == 0 || ds.Tables[1].Rows[0]["A4CLLastMeterReading"] == DBNull.Value) ? "0" : ds.Tables[1].Rows[0]["A4CLLastMeterReading"].ToString(); } //Mail body StringBuilder sb = new StringBuilder(); sb.Append("<div style='width: 99%; font-family: Cambria, Georgia, serif; color: #565656; margin:10px'>"); sb.Append("<center><img src='http://aegiscrm.in/images/Aegis_CRM_Logo.png' alt='AEGIS CRM' />"); sb.Append("<h2>Aegis Customer Relationship Management Notification</h2><br /></center>"); sb.Append("Date:- " + DateTime.Now.ToString("dd/MM/yyyy") + "<br /><br />"); sb.Append("Dear Aegis CRM Admin,<br />"); sb.Append("A customer/employee has made a low tonner request and waiting for approval.<br /><br />"); sb.Append("<b><u>Low Toner Request Details</u>:<br /><br />"); sb.Append("Toner Request No - " + TonnerRequestNo + "<br />"); sb.Append("Customer Name - " + CustomerName + "<br />"); sb.Append("Request Date and Time - " + System.DateTime.Now.ToString("dd/MM/yyyy hh:mm tt") + "<br />"); sb.Append("A3 B/W Current Meter Reading - " + A3BWCurrentMeterReading + "<br />"); sb.Append("A3 CL Current Meter Reading - " + A3CLCurrentMeterReading + "<br />"); sb.Append("A4 B/W Current Meter Reading - " + A4BWCurrentMeterReading + "<br />"); sb.Append("A4 CL Current Meter Reading - " + A4CLCurrentMeterReading + "<br />"); sb.Append("A3 B/W Last Toner Reading - " + A3BWLastMeterReading + "<br />"); sb.Append("A3 CL Last Toner Reading - " + A3CLLastMeterReading + "<br />"); sb.Append("A4 B/W Last Toner Reading - " + A4BWLastMeterReading + "<br />"); sb.Append("A4 CL Last Toner Reading - " + A4CLLastMeterReading + "<br />"); sb.Append("Model Name - " + ModelName + "<br />"); sb.Append("Machine ID - " + MachineId + "<br />"); sb.Append("Toner Name - " + TonnerName + "<br />"); sb.Append("Toner Yield- " + Yield + "</b><br /><br />"); sb.Append("Click to login into portal <a href='http://aegiscrm.in'>aegiscrm.in</a><br /><br />"); sb.Append("<hr />"); sb.Append("<center tyle='color:#C68E17'>*** This is a system generated mail. Please do not reply. ***</center>"); sb.Append("</div>"); //string fromMail = "", toMail = "", password = "", subject = ""; //fromMail = "*****@*****.**"; //password = "******"; //toMail = "*****@*****.**"; //subject = "Low Toner Request Notification"; //Business.Common.MailFunctionality.SendMail_HostingRaja(fromMail, toMail, password, subject, sb.ToString()); } }