Email 如何使用QTP捕获WebLISTIVE值,并将该值放在句子中间的电子邮件正文中 我发现了一个类似的问题,它询问如何获得一个WebLIST的值并将其放在Excel文件中,然后用电子邮件发送Excel文件,但是如何将WebLIST的值放在句子中间的电子邮件正文中而不在Excel文件中?

Email 如何使用QTP捕获WebLISTIVE值,并将该值放在句子中间的电子邮件正文中 我发现了一个类似的问题,它询问如何获得一个WebLIST的值并将其放在Excel文件中,然后用电子邮件发送Excel文件,但是如何将WebLIST的值放在句子中间的电子邮件正文中而不在Excel文件中?,email,qtp,Email,Qtp,例如,我想捕获一个WebElement,它告诉我我有多少可口可乐积分,然后我想通过电子邮件向自己发送该值。比如:“你现在有500点可乐积分” 这就是我所拥有的,但我得到了一个语法错误: Dim ResultsFile Set objOutlook=CreateObject("Outlook.Application") Set objOutlookMsg=objOutlook.CreateItem(olMailItem) objOutlookMsg.To="email@email.com" Res

例如,我想捕获一个WebElement,它告诉我我有多少可口可乐积分,然后我想通过电子邮件向自己发送该值。比如:“你现在有500点可乐积分”

这就是我所拥有的,但我得到了一个语法错误:

Dim ResultsFile
Set objOutlook=CreateObject("Outlook.Application")
Set objOutlookMsg=objOutlook.CreateItem(olMailItem)
objOutlookMsg.To="email@email.com"
ResultsFile="C:\Documents and Settings\Administrator\My Documents\CkeZeroPoints.xlsx"
objOutlookMsg.Subject="Coke Zero points"
objOutlookMsg.Body="You now have" &Browser("Sweepstakes.*").Page("Sweepstakes.*").WebElement("htmlID:=glPointsText").GetRoProperty("innertext") "Coke Zero points."
objOutlookMsg.Attachments.Add(ResultsFile)
objOutlookMsg.Display
objOutlookMsg.Send
Set objOutlookMsg=Nothing
Set objOutlook=Nothing
语法错误从第7行开始

提前谢谢你。

你忘了带符号(
&
):

Dim结果文件,innerText
设置objOutlook=CreateObject(“Outlook.Application”)
设置objOutlookMsg=objOutlook.CreateItem(olMailItem)
'最好将任务分开,以便尽早捕获错误
innerText=浏览器(“抽奖。*”).Page(“抽奖。*”).WebElement(“htmlID:=glPointsText”).getroperty(“innerText”)
ResultsFile=“C:\Documents and Settings\Administrator\My Documents\CkeZeroPoints.xlsx”
'在这里,您可以用单独的方法重构电子邮件处理
objOutlookMsg.To=”email@email.com"
objOutlookMsg.Subject=“焦炭零点”
objOutlookMsg.Body=“您现在拥有”&innerText&“可口可乐零点”
Dim ResultsFile, innerText
Set objOutlook=CreateObject("Outlook.Application")
Set objOutlookMsg=objOutlook.CreateItem(olMailItem)

' Better to separate tasks so you can trap errors earlier
innerText = Browser("Sweepstakes.*").Page("Sweepstakes.*").WebElement("htmlID:=glPointsText").GetRoProperty("innertext")
ResultsFile = "C:\Documents and Settings\Administrator\My Documents\CkeZeroPoints.xlsx"

' email handling here, you can refactor this in a separate method
objOutlookMsg.To  ="email@email.com"
objOutlookMsg.Subject = "Coke Zero points"
objOutlookMsg.Body = "You now have " & innerText & " Coke Zero points."  ' <-- ampersand added on this line.
objOutlookMsg.Attachments.Add ResultsFile  ' <-- parenthesis removed, only us parenthesis if
                                           ' you are calling a (returning) function
objOutlookMsg.Display
objOutlookMsg.Send
Set objOutlookMsg = Nothing
Set objOutlook = Nothing