Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Hta that send mails quering the printer description.

Posted on 2008-09-29
2
Medium Priority
?
323 Views
Last Modified: 2012-05-05
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

0
Comment
Question by:bsharath
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 58

Accepted Solution

by:
tigermatt earned 2000 total points
ID: 22599000
The code you posted doesn't appear to be in HTA form. However, I've modified it to add the CC mail, let me know of any further changes.

You need to set the Subject line for both the To and CC messages, and then obviously the email addresses for the To and CC messages. The rest will take care of itself.

Matthew
Dim strComputer, strEmailServer, strEmailSender, strEmailTo, MyVar, objWMIService, colInstalledPrinters, strMessage, strEmailCC, strSubjectCC
strComputer = "."
strEmailServer = "MAILSERVER" 'Mail Server Name
strEmailSender = "youname@domain.com" 'Sender Address
strEmailTo = "yourname@domain.com" 'The TO Email Address
strEmailCC = "the-CC-email@domain.com" 'Address to CC to
strSubjectCC = "CC Message Subject" 'The Subject for the CC
strSubjectTo = "TO Message Subject" 'The Subject for the mail sent to the "To" address
 
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 = strSubjectTo
.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
 
Set objMessage = CreateObject("CDO.Message")
with objMessage
.Sender = strEmailSender
.To = strEmailCC
.Subject = strSubjectCC 
.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

0
 
LVL 11

Author Comment

by:bsharath
ID: 22602429
Thank U Matthew... Sorry put in the wrong code here
Here is the new post
http://www.experts-exchange.com/Programming/Languages/Scripting/Q_23773550.html
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question