Link to home
Start Free TrialLog in
Avatar of bsharath
bsharathFlag for India

asked on

Hta that send mails quering the printer description.

Hi,

Hta that send mails quering the printer description.

1. When clicked SEND there should be 2 mails sent in 1 send.

One thats already doing now and another mail to a different TO & CC with a different subject. But the body can be the same.

So in one go i get a call log raised with the vendor and a call log raised in the company logging system also.

Regards
Sharath
Dim strComputer, strEmailServer, strEmailSender, strEmailTo, MyVar, objWMIService, colInstalledPrinters, strMessage
strComputer = "."
strEmailServer = "MAILSERVER"
strEmailSender = "youname@domain.com"
strEmailTo = "yourname@domain.com"
 
Do Until MyVar = 1
	MyVar = 0
	Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
	Set colInstalledPrinters =  objWMIService.ExecQuery ("Select * from Win32_PrintJob WHERE TotalPages > 100",,48)
	For Each objPrinter in colInstalledPrinters
		strMessage =	"Name: "            & objPrinter.Name   & Chr(10) & Chr(13) & _
				"Print Job Owner: " & objPrinter.Owner  & Chr(10) & Chr(13) & _
				"Total Pages: "  & objPrinter.TotalPages & Chr(10) & Chr(13)
		ShowAlert(strMessage)
	Next
	WScript.Sleep(1000*10)
Loop
 
Sub ShowAlert(msg)
 
'On Error Resume Next
Dim objMessage
Set objMessage = CreateObject("CDO.Message")
with objMessage
.Sender = strEmailSender
.To = strEmailTo
.Subject = "Print Server Alert" 
.TextBody = msg
.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 
 
.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strEmailServer 
 
.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 
 
.Configuration.Fields.Update
.Send
end with 
Set objMessage = Nothing
 
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of tigermatt
tigermatt
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bsharath

ASKER