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 ("Backup server 10.158.32.142 less than 40G, clean up the historical backup file or add disk space, otherwise the backup will terminate abnormally")
End If
Next
' Define a function to check whether daily backups are generated
Function Checkfile (ByVal textbody)
Const email_from = "[email protected]" ' Sender mailbox
Const Password = "123456" ' Sender's mailbox password
Const email_to = "[Email protected]; [Email protected] "' Recipient mailbox
Set CDO = CreateObject ("CDO. Message ") ' Create Cdo.message Object
Cdos. Subject = "Insufficient disk space" message subject
Cdos. from = Email_from ' Sender address
Cdos. to = Email_to ' recipient address
Cdos. TextBody = TextBody ' message body
' CDO. AddAttachment = "C:\hello.txt" Message attachment file path
Const schema = "http://schemas.microsoft.com/cdo/configuration/" ' provisions must be this, I don't know why
With CDO. Configuration.fields ' Reduce code input with the WITH keyword
. Item (Schema & "sendusing") = 2 ' Use the SMTP server on the network instead of the local SMTP server
. Item (Schema & "smtpserver") = "smtp.163.com" ' SMTP server address
. Item (Schema & "smtpauthenticate") = 1 ' Server authentication mode
. Item (Schema & "sendusername") = Email_from ' Sender mailbox
. Item (Schema & "Sendpassword") = Password ' sender's mailbox password
. Item (Schema & "smtpserverport") = ' SMTP Server port '
. Item (Schema & "Smtpusessl") = True ' Whether SSL is used
. Item (Schema & "smtpconnectiontimeout") = 60 ' timeout time to connect to the server
. Update ' Updates ' settings
End with
Cdos. Send ' e-mail
End function