调用方法是否有问题?作者: TIB 时间: 2010-11-27 21:37
也可以用CDO对象来发送Email,参考:
Function SendMail(buildversion , buildlog ,FxCop_Result,MetricsReport,Simian_ResultFile, 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")=EmailServer
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")=Eamil_sendusername
oConf.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword")=Email_sendpassword
oConf.Fields("http://schemas.microsoft.com/cdo/configuration/smtpusessl")=0
oConf.Fields.Update()
'通过CDO的 Message对象设置邮件主题、附件、发送人等信息
oMessage.Configuration = oConf
oMessage.To = Email_ReceiveAddress
oMessage.From = Email_SendAddress
oMessage.Subject = buildversion & "构建结果"
oMessage.AddAttachment( buildlog )
if (FxCop_Result<>"") Then
oMessage.AddAttachment( FxCop_Result )
End If
if (MetricsReport<>"") Then
oMessage.AddAttachment( MetricsReport )
End If
if (Simian_ResultFile<>"") Then
oMessage.AddAttachment( Simian_ResultFile )
End If
If deBugbuildResult = true Then
TextBody = buildversion & "编译成功!"
Else
TextBody = buildversion & "编译失败!"
End If
Set objMessage = CreateObject("CDO.Message")
Set objConfig = CreateObject("CDO.Configuration")
Set Fields = objConfig.Fields
Set objMessage.Configuration = objConfig