'An example of report C: drive space and send out email with SMTP server defined.
'=============================================================
'CDO can be support by XP and windows 2000 professinal which
'has been tested successfully
'=============================================================
Dim strSpace
Dim strComputer, objNetwork
Set objNetwork = WScript.CreateObject("WScript.Network")
Set objMessage = CreateObject("CDO.Message")
set fs = CreateObject("Scripting.FileSystemObject")
set drive = fs.GetDrive("C:\")
strComputer = objNetwork.ComputerName
objMessage.Subject = "daily report of available C drive space in " & strComputer
objMessage.From = "icil_sup@icil.net"
objMessage.To = "allenzhang@icil.net,havingchan@icil.net"
strSpace = "Available Space on C:\:" & FormatNumber(drive.AvailableSpace/1024^2) & "MB"
objMessage.TextBody = now & vbTab & strComputer & strSpace
'==This section provides the configuration information for the remote SMTP server.
'==Normally you will only change the server name or IP.
objMessage.Configuration.Fields.Item _
("") = 2
'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("") = "192.168.18.2"
'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("port") = 25
objMessage.Configuration.Fields.Update
'==End remote SMTP server configuration section==
objMessage.Send
'An example of send out email using MAPI which request outlook or OE can send out 'email correctly.
'=================================================================================
'CDONTS seems only support by NT or windows2000 servers only,XP can't support it
'Don't try use below in XP
'=================================================================================
Dim strComputer, objNetwork
Set objNetwork = WScript.CreateObject("WScript.Network")
Set objMessage = CreateObject("CDONTS.NewMail")
set fs = CreateObject("Scripting.FileSystemObject")
set drive = fs.GetDrive("C:\")
strComputer = objNetwork.ComputerName
objMessage.Subject = "Daily report of C drive available space on " & strComputer
objMessage.From = "icil_sup@icil.net"
objMessage.To = "allenzhang@icil.net,havingchan@icil.net"
strSpace = "Available Space on C:\:" & FormatNumber(drive.AvailableSpace/1024^2) & "MB"
objMessage.Body = Now & vbtab & strComputer & vbtab & strSpace
objMessage.Send
'Another example of send email with smtp authentication from MSDN but I still 'failed to send it out with error code 0x80040217 "server response: not available"
'================================================================================
'An example of report C: drive space and send out email with SMTP server defined.
'=============================================================
'CDO can be support by XP and windows 2000 professinal which
'has been tested successfully
'=============================================================
Dim strSpace
Dim strComputer, objNetwork
Set objNetwork = WScript.CreateObject("WScript.Network")
Set objMessage = CreateObject("CDO.Message")
set fs = CreateObject("Scripting.FileSystemObject")
set drive = fs.GetDrive("C:\")
strComputer = objNetwork.ComputerName
objMessage.Subject = "daily report of available C drive space in " & strComputer
objMessage.From = "icil_sup@icil.net"
objMessage.To = "allenzhang@icil.net"
strSpace = "Available Space on C:\:" & FormatNumber(drive.AvailableSpace/1024^2) & "MB"
objMessage.TextBody = now & vbTab & strComputer & strSpace
'==This section provides the configuration information for the remote SMTP server.
'==Normally you will only change the server name or IP.
objMessage.Configuration.Fields.Item _
("") = 2
objMessage.Configuration.Fields.Item _
("") = 1
objMessage.Configuration.Fields.Item _
("") = False
'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("") = "smtp.163.com"
objMessage.Configuration.Fields.Item _
("") = "langsuifeng210@163.com"
objMessage.Configuration.Fields.Item _
("") = text_password
'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("port") = 25
objMessage.Configuration.Fields.Update
'==End remote SMTP server configuration section==
objMessage.Send
阅读(1237) | 评论(0) | 转发(0) |