|
VBS发送Emial的例子:
Function SendMail(buildversion , buildlog , deBugbuildResult)
Set oMessage=WScript.CreateObject("CDO.Message")
Set oConf=WScript.CreateObject("CDO.Configuration")
'创建CDO.Configuration对象后,需要设置邮件服务器的端口、用户帐号等相关信息
oConf.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
oConf.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver")="192.168.0.2"
oConf.Fields("http://schemas.microsoft.com/cdo/configuration/serverport")=25
oConf.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate")=1
oConf.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername")="tester1"
oConf.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword")="123456"
oConf.Fields("http://schemas.microsoft.com/cdo/configuration/smtpusessl")=0
oConf.Fields.Update()
'通过CDO的 Message对象设置邮件主题、附件、发送人等信息
oMessage.Configuration = oConf
oMessage.To = "tester1@cnj.com,tester2@cnj.com"
oMessage.From = "tester1@cnj.com"
oMessage.Subject = "每日构建结果"
oMessage.AddAttachment( buildlog )
If deBugbuildResult = true Then
TextBody = "编译成功!"
Else
TextBody = "编译失败!"
End If
oMessage.TextBody = TextBody
oMessage.Send()
End Function |
|