Advertisement
Guest User

Untitled

a guest
Jul 19th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.76 KB | None | 0 0
  1. string EPT;
  2. string PRINTER;
  3. string CID;
  4. 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 > ";
  5.  
  6. foreach (RetrieveDeviceData deviceData in SPOSStatusList)
  7. {
  8. if (deviceData.EPTStatus.Contains("EPT is not returning any error on commands"))
  9. {
  10. EPT = "EPT OK";
  11. }
  12. else if (!deviceData.EPTStatus.Contains("NA"))
  13. {
  14. EPT = "EPT Not OK";
  15. }
  16. else
  17. {
  18. EPT = "NA";
  19. }
  20.  
  21. if (deviceData.PRINTERStatus.Contains("PRINTER - OK"))
  22. {
  23. PRINTER = "PRINTER OK";
  24. }
  25. else if (!deviceData.PRINTERStatus.Contains("NA"))
  26. {
  27. PRINTER = "PRINTER Not OK";
  28. }
  29. else
  30. {
  31. PRINTER = "NA";
  32. }
  33.  
  34. if (deviceData.CIDStatus.Contains("CID-OK"))
  35. {
  36. CID = "CID OK";
  37. }
  38. else if (!deviceData.CIDStatus.Contains("NA"))
  39. {
  40. CID = "CID Not OK";
  41. }
  42. else
  43. {
  44. CID = "NA";
  45. }
  46.  
  47. 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 >";
  48. }
  49.  
  50.  
  51. htmlString = htmlString + "</ table >< br /><br /> Regards < br /> Presto CTSS </ body ></ html>";
  52.  
  53.  
  54.  
  55. MailMessage mailMessage = new MailMessage();
  56. mailMessage.From = new MailAddress(ConfigurationManager.AppSettings["mailFrom"].ToString());
  57. mailMessage.To.Add(new MailAddress(ConfigurationManager.AppSettings["mailTo"].ToString()));
  58. mailMessage.Subject = "PDS SPOS Device Status Report - " + DateTime.Now;
  59. mailMessage.IsBodyHtml = true;
  60. mailMessage.Body = htmlString;
  61.  
  62. SmtpClient client = new SmtpClient();
  63. Attachment attachment = new Attachment(reportPath + "\SPOSStatusReport.csv");
  64. mailMessage.Attachments.Add(attachment);
  65. client.Host = ConfigurationManager.AppSettings["mailServerIp"].ToString();
  66. try
  67. {
  68. client.Send(mailMessage);
  69. writer.WriteLine("Email sent");
  70. }
  71. catch(Exception e)
  72. {
  73. writer.WriteLine(e.ToString());
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement