Windows environment VB Monitoring script!

Source: Internet
Author: User


File monitoring


DIM strdate

DIM Strdatestringold

DIM StrPath01, strpath02,strpath03

DIM FS

DIM TextBody


Strdate = Date

Strdatestringold=year (strdate) & Right ("0" & Month (Strdate), 2) & Right ("0" & Day (Strdate), 2) & ". rar "


Strpath= "D:\backup\10.65.14.61\" &strdatestringold

strpath01= "D:\backup\10.65.14.61\" &strdatestringold


Set FS =createobject ("Scripting.FileSystemObject")


If fs.fieexists (strPath01) =fales Then

TextBody = "The following backup files are not generated" & vbCrLf & StrPath01

End If


If fs.fieexists (strPath02) =fales Then

TextBody =textbody & vbCrLf & strPath02

End If


If TextBody <> "then

Call Checkfile (TextBody)

End If


' Define a function to check whether daily backups are generated


Function Checkfile (ByVal textbody)

Const email_from = "[email protected]" ' Sender mailbox

Const Password = "Dw_chaoyue" ' Sender mailbox password

Const email_to = "[Email protected]; [Email protected] "' Recipient mailbox


Set CDO = CreateObject ("CDO. Message ") ' Create Cdo.message Object

Cdos. Subject = "Warning: Backup file exception" 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


Code Reference Links:

Http://www.jb51.net/article/26105.htm



This article is from the "SQL Server MySQL" blog, so be sure to keep this source http://dwchaoyue.blog.51cto.com/2826417/1539852

Related Article

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.