Chinaunix首页 | 论坛 | 博客
  • 博客访问: 146965
  • 博文数量: 52
  • 博客积分: 1410
  • 博客等级: 上尉
  • 技术积分: 490
  • 用 户 组: 普通用户
  • 注册时间: 2007-11-05 12:05
文章分类

全部博文(52)

文章存档

2013年(1)

2010年(3)

2009年(6)

2008年(25)

2007年(17)

我的朋友

分类:

2008-04-11 11:53:26

'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

阅读(1209) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~