1 '///Wriiten by Ed Dondlinger 1/23/2009 - edondlinger@thepylegroup.com ///
3 '/// MODIFY THE VARIABLES LISTED BELOW IN THE "USER VARIABLES" SECTION.
4 '/// THEN RENAME FILE WITHOUT THE ".example" SUFFIX.
6 '///Comment out the next line when testing, then change back when done. ///
11 set oShell
= CreateObject("WScript.Shell")
13 '/// Get APCUPS Status Report ///
15 set Get_Status
= oShell
.exec("%comspec% /c c:\Progra~1\apcupsd\bin\apcaccess.exe status")
16 UPS_Status
= Get_Status
.StdOut
.readall
18 '/// Get Time Zone info from local windows registry ///
20 atb
= "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TimeZoneInformation\StandardName"
21 TZInfo
= oShell
.RegRead(atb
)
25 'XXXXXXXXXXXXXXXXXXXX USER VARIABLES XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXxXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
29 MyEmailSubject
= "POWER RESTORED at: " & MyLocation
31 MyEmailFromAddress
= "xxx@zzz.com" 'you could also use this format to display the common name: """Me"" <user@mydomain.com>"
33 MyEmailToAddress
= "xxx@zzz.com"
35 MyTextBody
= "The power has been restored at: " & MyLocation
& " and the UPS is running on utility power." & _
36 vbCRLF
& "Reported by the APCUPS Server at: " & dateAdd("H",0,Now
) & " " & _
37 TZInfo
& vbcrlf
& vbcrlf
& UPS_Status
39 MySMTPServer
= "smtp.gmail.com" 'or use a IP address i.e. "10.x.x.x"
41 MyMailServerUserName
= "UName"
43 MyMailServerPW
= "Password"
45 MySMTPServerPort
= 465
47 MySMTPServerSSL
= True
49 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXxXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
54 '////////// Email Section //////////
56 '*** NOTE: MSDN CDO Library can be referenced at: http://msdn.microsoft.com/en-us/library/ms872853(EXCHG.65).aspx
58 Const cdoSendUsingPickup
= 1 'Send message using the local SMTP service pickup directory.
59 Const cdoSendUsingPort
= 2 'Send the message using the network (SMTP over the network).
60 Const cdoSendUsingExchange
= 3 'Send the message using MS Exchange Mail Server.
62 Const cdoAnonymous
= 0 'Do not authenticate
63 Const cdoBasic
= 1 'basic (clear-text) authentication
64 Const cdoNTLM
= 2 'NTLM
66 Const cdoURL
= "http://schemas.microsoft.com/cdo/configuration/"
68 Set objMessage
= CreateObject("CDO.Message")
70 '/// Set the message properties. ///
74 .Subject
= MyEmailSubject
76 .From
= MyEmailFromAddress
78 .To = MyEmailToAddress
80 .TextBody
= MyTextBody
82 'Set Mail Importance level, you can set [high,normal,low]
83 .fields
.Item("urn:schemas:mailheader:importance").Value
= "high"
85 'Set Mail priority level, you can set [1=urgent, 0=normal, -1=nonurgent]
86 .fields
.Item("urn:schemas:mailheader:priority").Value
= 1
92 '/// This section provides the configuration information for the remote SMTP server. ///
94 with objMessage
.Configuration
.Fields
96 'Send Using method (1 = local smtp, 2 = remote network smtp, 3 = MS Exchange)
97 .Item(cdoURL
& "sendusing") = 2
99 'Name or IP of Remote SMTP Server
100 .Item(cdoURL
& "smtpserver") = MySMTPServer
102 'Type of authentication, NONE, Basic (Base64 encoded), NTLM
103 .Item(cdoURL
& "smtpauthenticate") = cdoBasic
105 'Your UserID on the SMTP server
106 .Item(cdoURL
& "sendusername") = MyMailServerUserName
108 'Your password on the SMTP server
109 .Item(cdoURL
& "sendpassword") = MyMailServerPW
111 'Server port (typically 25)
112 .Item(cdoURL
& "smtpserverport") = MySMTPServerPort
114 'Use SSL for the connection (False or True)
115 .Item(cdoURL
& "smtpusessl") = MySMTPServerSSL
117 'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
118 .Item(cdoURL
& "smtpconnectiontimeout") = 60
126 '/// Send the message ///
133 Set objMessage
= nothing
135 set Get_Status
= nothing
137 '/// Exit with a 0 error level to ensure the apccontrol.bat continues ///