Reeks objNetwork = CreateObject („WScript.Network“)
Vastgestelde objADSysInfo = CreateObject („ADSystemInfo“)
Reeks objUser = GetObject („LDAP: /“ & objADSysInfo.UserName)
'E-mailvariabelen:
strServer = „mailhost.abc.com“
strTo = „[email protected]“
strFrom = „[email protected]“
strSubject = „Onderwerp hier“
strBody = „Naam: “ & objUser.givenName & „„& objUser.sn & VbCrLf & _
De „naam van de opening van een sessie: “ & objUser.samAccountName & VbCrLf & VbCrLf & „Printers: “
Vastgestelde objPrinters = objNetwork.EnumPrinterConnections
Voor intPrinter = 0 aan objPrinters.Count - 1 Stap 2
strBody = strBody & VbCrLf & objPrinters (intPrinter) & vbTab & objPrinters (intPrinter + 1)
Daarna
strComputer = „.“
Vastgestelde objWMIService = GetObject („winmgmts: {impersonationLevel=impersonate}! \ \“ & strComputer & „\ wortel \ cimv2“)
Reeks colComputer = objWMIService.ExecQuery („Uitgezochte Fabrikant, Model van Win32_ComputerSystem“)
Voor Elke objComputer in colComputer
strManufacturer = „Fabrikant: “ & objComputer.Manufacturer
strModel = „Model: “ & objComputer.Model
Daarna
strBody = strBody & VbCrLf & Naam van VbCrLf & de „van de Computer: “ & van objNetwork.ComputerName & van VbCrLf & „van de Computer Model: “ & strModel
SendEmail strServer, strBody strTo, strFrom, strSubject,
MsgBox „E-mail is verzonden.“
Sub SendEmail (strServer, strBody strTo, strFrom, strSubject,)
Schemerige objMessage
Vastgestelde objMessage = CreateObject („CDO.Message“)
objMessage.To = strTo
objMessage.From = strFrom
objMessage.Subject = strSubject
objMessage.TextBody = strBody
'de ==Thissectie verstrekt de configuratieinformatie voor de verre server SMTP.
objMessage.Configuration.Fields.Item („http://schemas.microsoft.com/cdo/configuration/sendusing“) = 2
'Naam of IP van Verre Server SMTP
objMessage.Configuration.Fields.Item („http://schemas.microsoft.com/cdo/configuration/smtpserver“) = strServer
De 'haven van de server (typisch 25)
objMessage.Configuration.Fields.Item („http://schemas.microsoft.com/cdo/configuration/smtpserverport“) = 25
objMessage.Configuration.Fields.Update
'==End verre SMTP serverconfiguratie section==
objMessage.Send
Vastgestelde objMessage = niets
Sub van het eind
|