以前写的一个用QTP登录Yahoo邮箱查收邮件的脚本,现在Yahoo的界面设计可能已经更改了,所以未必能跑通脚本,仅供参考:
' 启动IE浏览器
SystemUtil.Run "IEXPLORE.EXE"
' 导航至Yahoo邮箱页面
Browser("version:=inter.*").Navigate "http://mail.cn.yahoo.com/"
'登录Yahoo邮箱
Login "User1" , "123456"
' 查找指定发件人的指定主题的邮件
GetMail "Chen Neng Ji" ,"Test"
' 获取邮件主体内容
Msgbox GetMailContent
' Functions.............................................................................................................................................................................................................
Function Login( UserName ,Password )
'登录Yahoo邮箱并接收邮件
Browser("雅虎邮箱 - 全球邮箱第一品牌").Page("雅虎邮箱").WebEdit("login").Set UserName
Browser("雅虎邮箱 - 全球邮箱第一品牌").Page("雅虎邮箱").WebEdit("passwd").Set Password
Browser("雅虎邮箱 - 全球邮箱第一品牌").Page("雅虎邮箱").WebButton("登录").Click
' 接收邮件,打开邮件列表
Browser("雅虎邮箱 - 全球邮箱第一品牌").Page("Yahoo!电邮").WebButton("收信").Click
End Function
' 在邮件列表中查找指定发件人的指定主题的邮件,如果找到则点击进入
Function GetMail( sender , subject )
Set EmailList = Browser("雅虎邮箱 - 全球邮箱第一品牌").Page("Yahoo!电邮").WebTable("邮件列表")
For I =2 to EmailList.RowCount
Mail_sender = CSTR(EmailList.GetCellData(I,2))
Mail_subject = Trim(CSTR(EmailList.GetCellData(I,6)))
If (sender=Mail_sender) and (subject = Mail_subject )Then
Reporter.ReportEvent micDone,"Find Mail","Find Mail Succeed!"
EmailList.ChildItem(I,6,"Link",0).Click
Exit For
End If
Next
End Function
' 获取邮件主体内容
Function GetMailContent
GetMailContent = Browser("雅虎邮箱 - 全球邮箱第一品牌").Page("Yahoo!电邮").WebElement("邮件").WebElement("邮件主体内容").GetROProperty("innertext")
End Function