Advertisement
Guest User

Untitled

a guest
Jun 7th, 2018
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. strComputer = "print server"
  2. Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
  3. Set colErrorPrinters = objWMI.ExecQuery ("Select * From Win32_Printer WHERE DetectedErrorState = 5")
  4. If colErrorPrinters.Count > 0 Then
  5. strBody = "The following printers are indicating low toner:" & vbCrLf
  6.  
  7. For Each objPrinter in colErrorPrinters
  8. strBody = strBody & objPrinter.Name & vbCrLf
  9. Next
  10.  
  11. strBody = strBody & vbCrLf & "Please act now!"
  12.  
  13. Set objMessage = CreateObject("CDO.Message")
  14. With objMessage
  15. .Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
  16. .Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mailServerIP"
  17. .Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
  18. .Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
  19. .Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 0
  20.  
  21. .Configuration.Fields.Update
  22. .From = "[email protected]"
  23. .Subject ="Toner low on printers"
  24. .TextBody = strBody
  25. .Send
  26. End With
  27. End If
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement