kang322 发表于 2010-9-6 10:26:20

关于QTP发送邮件

各位大侠们,我想让QTP运行完后,将测试结果自动发送到我的邮箱中!请问该如何写这段代码呢?

TIB 发表于 2010-9-6 13:06:59

' 发送邮件
Function SendMail(LogFile)
        Set oMessage=WScript.CreateObject("CDO.Message")
        Set oConf=WScript.CreateObject("CDO.Configuration")
        Set fso = CreateObject("Scripting.FileSystemObject")
       
        '创建CDO.Configuration对象后,需要设置邮件服务器的端口、用户帐号等相关信息
        oConf.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
        oConf.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver")=192.168.1.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")="xxx"
        oConf.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword")="xxx"
        oConf.Fields("http://schemas.microsoft.com/cdo/configuration/smtpusessl")=0
        oConf.Fields.Update()
       
        '通过CDO的 Message对象设置邮件主题、附件、发送人等信息
        oMessage.Configuration = oConf
        oMessage.To = "xxx"
        oMessage.From = "xxx"
        oMessage.Subject = "QTRunner Notification"
        file = fso.GetAbsolutePathName(LogFile)
        Set fso = Nothing
        oMessage.AddAttachment( file )

        TextBody = "QTRunner Finish! See attachment for logs."          
        oMessage.TextBody = TextBody
        oMessage.Send()
End Function


参考QTRunner:
http://www.cnblogs.com/testware/archive/2010/05/14/1735545.html

kang322 发表于 2010-9-6 13:56:29

回复 2# 的帖子

高手啊!

koogardenia 发表于 2010-9-7 11:01:58

http://schemas.microsoft.com/cdo/configuration

這地址是什麽?用在腳本里報錯的..
請問要改成什麽

vikesgao 发表于 2010-10-11 14:46:58

高手啊!
页: [1]
查看完整版本: 关于QTP发送邮件