Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- strComputer = "print server"
- Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
- Set colErrorPrinters = objWMI.ExecQuery ("Select * From Win32_Printer WHERE DetectedErrorState = 5")
- If colErrorPrinters.Count > 0 Then
- strBody = "The following printers are indicating low toner:" & vbCrLf
- For Each objPrinter in colErrorPrinters
- strBody = strBody & objPrinter.Name & vbCrLf
- Next
- strBody = strBody & vbCrLf & "Please act now!"
- Set objMessage = CreateObject("CDO.Message")
- With objMessage
- .Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
- .Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mailServerIP"
- .Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
- .Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
- .Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 0
- .Configuration.Fields.Update
- .To = "[email protected]"
- .From = "[email protected]"
- .Subject ="Toner low on printers"
- .TextBody = strBody
- .Send
- End With
- End If
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement