邮件收发功能使用说明
使用目的:该程序用于实现物理带库添加磁带后自动清点功能。
程序组成:有两个脚本组成,netbackup.bat和sendmail.vbs。
存放目录:D:\nbu_inventory_daily下
运行机制:该程序由Windows操作系统的计划任务调用执行,每天下午5点发起调用操作。执行时,先执行netbackup.bat进行磁带库的清点操作,并记录报告;然后会自动调用sendmail.vbs,并完成邮件发送功能,将报告以附件形式发出。
相关参数:
在netbackup.bat脚本中,
vmupdate.exe,实现带库的清点操作,并记录报告。
之后,自动调用sendmail.vbs脚本。
在sendmail.vbs脚本中,
Email.From,是邮件发送人;
Email.To,是邮件收件人;
Email.Cc,是邮件抄送人;
Email.Bcc,是邮件密送人;
Email.Subject,是邮件标题;
Email.Textbody,是邮件内容。
--netbackup
脚本:"C:\Program Files\Veritas\Volmgr\bin\vmupdate.exe" -rt TLD -rn 2 -mt HCART2 -p offline_ppool -h ccn-nbu-clu > D:\nbu_inventory_daily\%date:~-4%%date:~-10,-8%%date:~-7,-5%.txt
D:\nbu_inventory_daily\sendmail.vbs
--sendmail
NameSpace = ""
Function sbday
sbday=FormatDateTime(now,2)
End Function
yy=right("0000"&year(sbday),4)
mm=right("00"&month(sbday),2)
dd=right("00"&day(sbday),2)
sdt=yy & mm & dd
file="D:\nbu_inventory_daily\" & sdt & ".txt"
Set Email = CreateObject("CDO.Message")
Email.From = ""
Email.To =
Email.Cc = "mail"
Email.Bcc = ""
Const ForReading = 1, ForWriting = 2, ForAppending = 8
dim fso, f
Set fso = Createobject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(file, ForReading)
BodyText = f.ReadAll
'Set o = CreateObject("Scripting.FileSystemObject")
's = o.OpenTextFile( file ).ReadAll()
's = o.OpenTextFile(file).ReadAll()
'If InStr(s, "Volume configuration is up-to-date with robot contents.") <> 0 Then
'Email.Subject = "normal"
'Else
'If InStr(s, "Volume configuration successfully updated") <> 0 Then
'Email.Subject = "success"
'Else
'Email.Subject = "faild"
'End if
'End if
f.Close
Set f = Nothing
Set fso = Nothing
Email.Subject = sdt & "ccn-nbu-clu check report"
Email.Textbody = BodyText
'Email.AddAttachment file
With Email.Configuration.Fields
.Item(NameSpace&"sendusing") = 2
.Item(NameSpace&"smtpserver") = "ccn-bj-hub01.cn.canon-asia.com"
.Item(NameSpace&"smtpserverport") = 25
.Item(NameSpace&"smtpauthenticate") = 1
.Update
End With
Email.Send
阅读(1966) | 评论(0) | 转发(0) |