Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string EPT;
- string PRINTER;
- string CID;
- string htmlString= "<!DOCTYPE html>< html >< body > Hi All, < br /> < br /> Please find below, status of PDS SPOS Devices < br />< br /> < table border='1' >< tr >< th > Device Name </ th >< th > Online Status </ th >< th > Device Status </ th >< th > EPT Status </ th >< th > PRINTER Status </ th >< th > CID Status </ th ></ tr > ";
- foreach (RetrieveDeviceData deviceData in SPOSStatusList)
- {
- if (deviceData.EPTStatus.Contains("EPT is not returning any error on commands"))
- {
- EPT = "EPT OK";
- }
- else if (!deviceData.EPTStatus.Contains("NA"))
- {
- EPT = "EPT Not OK";
- }
- else
- {
- EPT = "NA";
- }
- if (deviceData.PRINTERStatus.Contains("PRINTER - OK"))
- {
- PRINTER = "PRINTER OK";
- }
- else if (!deviceData.PRINTERStatus.Contains("NA"))
- {
- PRINTER = "PRINTER Not OK";
- }
- else
- {
- PRINTER = "NA";
- }
- if (deviceData.CIDStatus.Contains("CID-OK"))
- {
- CID = "CID OK";
- }
- else if (!deviceData.CIDStatus.Contains("NA"))
- {
- CID = "CID Not OK";
- }
- else
- {
- CID = "NA";
- }
- htmlString = htmlString + "< tr >< td >" + deviceData.DeviceName.ToString() + "</ td >< td >" + deviceData.OnlineStatus.ToString() + "</ td >< td >" + deviceData.DeviceStatus.ToString() + "</ td >< td >" + EPT.ToString() + "</ td >< td >" + PRINTER.ToString() + "</ td >< td >" + CID.ToString() + "</ td ></ tr >";
- }
- htmlString = htmlString + "</ table >< br /><br /> Regards < br /> Presto CTSS </ body ></ html>";
- MailMessage mailMessage = new MailMessage();
- mailMessage.From = new MailAddress(ConfigurationManager.AppSettings["mailFrom"].ToString());
- mailMessage.To.Add(new MailAddress(ConfigurationManager.AppSettings["mailTo"].ToString()));
- mailMessage.Subject = "PDS SPOS Device Status Report - " + DateTime.Now;
- mailMessage.IsBodyHtml = true;
- mailMessage.Body = htmlString;
- SmtpClient client = new SmtpClient();
- Attachment attachment = new Attachment(reportPath + "\SPOSStatusReport.csv");
- mailMessage.Attachments.Add(attachment);
- client.Host = ConfigurationManager.AppSettings["mailServerIp"].ToString();
- try
- {
- client.Send(mailMessage);
- writer.WriteLine("Email sent");
- }
- catch(Exception e)
- {
- writer.WriteLine(e.ToString());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement