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