Windows environment VB disk space Monitoring script!

Source: Internet
Author: User


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


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.