码迷,mamicode.com
首页 > Windows程序 > 详细

window 环境下vb 监控脚本!

时间:2014-08-14 17:00:39      阅读:243      评论:0      收藏:0      [点我收藏+]

标签: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 = "dwchaoyue@163.com" ‘发件人邮箱 

Const Password = "DW_chaoyue" ‘发件人邮箱密码 

Const Email_To = "835223319@qq.com;v.dengwang@snda.com" ‘收件人邮箱 


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

window 环境下vb 监控脚本!,布布扣,bubuko.com

window 环境下vb 监控脚本!

标签:window   监控   

原文地址:http://dwchaoyue.blog.51cto.com/2826417/1539852

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!