標籤:window 監控
檔案監控
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 = "以下備份檔案未產生" & vbcrlf & strPath01
End If
If fs.fieExists(strPath02)=fales Then
Textbody =Textbody & vbcrlf & strPath02
End If
if Textbody <>"" then
call CheckFile(Textbody)
end if
‘定義一個函數,檢查每天的備份是否產生
function CheckFile(byval TextBody )
Const Email_From = "[email protected]" ‘寄件者郵箱
Const Password = "DW_chaoyue" ‘寄件者郵箱密碼
Const Email_To = "[email protected];[email protected]" ‘收件者郵箱
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
代碼參考連結:
http://www.jb51.net/article/26105.htm
本文出自 “SQLServer MySQL” 部落格,請務必保留此出處http://dwchaoyue.blog.51cto.com/2826417/1539852