VBS发送多个附件邮件脚本

#   VBS发送多个附件邮件脚本



NameSpace = "http://schemas.microsoft.com/cdo/configuration/"
set Email = CreateObject("CDO.Message")
Email.From = "发件人地址"
Email.To = "收件人地址"
Email.Subject = "测试"
x="邮件内容文件的绝对路径        //d:\1.txt"
'y="附件绝对路径            //d:\bak.zip"
Set fso=CreateObject("Scripting.FileSystemObject")
Set myfile=fso.OpenTextFile(x,1,Ture)
c=myfile.readall
myfile.Close
Email.Textbody = c
'Email.AddAttachment y
with Email.Configuration.Fields
.Item(NameSpace&"sendusing") = 2
.Item(NameSpace&"smtpserver") = "邮箱服务器" 
.Item(NameSpace&"smtpserverport") = 25
.Item(NameSpace&"smtpauthenticate") = 1
.Item(NameSpace&"sendusername") = "用户名"  
.Item(NameSpace&"sendpassword") = "密码" 
.Update
end with
Email.Send
Set Email=Nothing
----------------------------------------------------------------------------------------
多个附件
----------------------------------------------
y="附件绝对路径            //d:\bak.zip"
z="附件绝对路径            //e:\bak.zip"
Email.AddAttachment y
Email.AddAttachment z
----------------------------------------------------------------------------------------
稍微改进下动态规则文件名就可以自动发送每天的备份文件到邮箱了
dim mailtitle
mailtitle="mssql bak"
dim filename
filename=now()

Email.Subject = filename & "mssqlbak"
x="d:\1.txt"
y="d:\mssqlbak\ceshi_backup_" & filename & "0000.bak"


# xiaoxiao [ 2015-12-01 ]

# Address in this article

# http://www.s7smile.com/local/1

# s7smile.com