Set objFSO = CreateObject ("Scripting.FileSystemObject")
Set colDrives = objFSO.Drives
Dim msg
For Each objDrive in colDrives
If objDrive.IsReady and objDrive.DriveLetter ="D" and int(objDrive.FreeSpace/(1024*1024*1024))<=400 Then
call CheckFile("备份服务器10.158.32.142的空间小于40G ,请清理历史备份文件或是添加磁盘空间,否则备份将异常终止")
End If
Next
‘定义一个函数,检查每天的备份是否生成
function CheckFile(byval TextBody )
Const Email_From = "dwchaoyue@163.com" ‘发件人邮箱
Const Password = "123456" ‘发件人邮箱密码
Const Email_To = "835223319@qq.com;v.dengwang@snda.com" ‘收件人邮箱
Set CDO = CreateObject("CDO.Message") ‘创建CDO.Message对象
CDO.Subject = "磁盘空间不足" ‘邮件主题
CDO.From = Email_From ‘发件人地址
CDO.To = Email_To ‘收件人地址
CDO.TextBody = TextBody ‘邮件正文
‘cdo.AddAttachment = "C:\hello.txt" ‘邮件附件文件路径
Const schema = "http://schemas.microsoft.com/cdo/configuration/" ‘规定必须是这个,我也不知道为什么
With CDO.Configuration.Fields ‘用with关键字减少代码输入
.Item(schema & "sendusing") = 2 ‘使用网络上的SMTP服务器而不是本地的SMTP服务器
.Item(schema & "smtpserver") = "smtp.163.com" ‘SMTP服务器地址
.Item(schema & "smtpauthenticate") = 1 ‘服务器认证方式
.Item(schema & "sendusername") = Email_From ‘发件人邮箱
.Item(schema & "sendpassword") = Password ‘发件人邮箱密码
.Item(schema & "smtpserverport") = 25 ‘SMTP服务器端口
.Item(schema & "smtpusessl") = True ‘是否使用SSL
.Item(schema & "smtpconnectiontimeout") = 60 ‘连接服务器的超时时间
.Update ‘更新设置
End With
CDO.Send ‘发送邮件
End function