Multiple Emails At One Click
Please find the below progam for sending number of mails at one go using QTP Tool, VBscript Discriptive Language, and Excel Document....Hope you will enjoy this :-)
NOTE: Object Properties may change based on browser versions and OS
Option explicit
Dim bro, url, wsho, exo, wbo, wso, nor, i, T, C, B, F
'open excel file sheet using VBScript
'Bro for browser
'url for website
'wsho for keyboard object
'exo for excel application
'wbo for excel work book
'wso for excel work sheet
'nor for number of rows count
'i for looping
'T for to addresses from excel sheet
'C for CC addresses from excel sheet
'B for mail body from excel sheet
'F for file path from excel sheet
Set exo=createobject ("Excel.application")
exo.visible=true
set wbo=exo.workbooks.open ("C:\Documents and Settings\qa\Desktop\QTP Practice\PATH FILES\email list.xls")
set wso=wbo.worksheets("sheet1")
nor=wso.usedrange.rows.count
for i = 2 to nor step 1 '(2 is used because first row is given for headings)
T=wso.cells (i, 1)
C=wso.cells (i, 2)
B=wso.cells (i, 3)
F=wso.cells (i, 4)
'Launch Yahoomail website using VBscript
Bro= "C:\Program Files\Internet Explorer\iexplore.exe"
url= "http://www.yahoomail.com"
invokeapplication (bro&" "&url)
'Do login using QTPscript in DPWith browser ("title:=.*")
With.page ("title:=.*")
.webedit ("name:=login").set "prasadxxxxx"
.webedit ("name:=passwd").setsecure "52e8ddowlf543cb5ec81f6e705d2ec5edc6f617883501c0445045f623"
.webbutton("name:=Sign In").click
End with
End with
With browser ("title:=.*")
With.page ("title:=.*")
'Using analog i have avoided a dailogboxWindow("Microsoft Internet Explorer").RunAnalog "Track1"
end with
end with
'Go to compose a new message using QTPscript with DP
With browser ("title:=.*")
With.page ("title:=.*")
.webbutton("name:=Compose", "index:=0").click
End with
End with
'Fill mail compose page using QTPscript with DP
With browser ("title:=.*")
With.page ("title:=.*")
.webedit("name:=to").set T
.webedit("name:=cc").set C
.webedit("name:=subj").set "QTP Automation Tool"
.webbutton("name:=Attach Files").Click
end with
end with
With browser ("title:=.*")
With.page ("title:=.*")
.webfile("name:=uploadfile").set F
.webbutton("name:=Attach Files").Click
end with
end with
With browser ("title:=.*")
With.page ("title:=.*")
'Automate Keyboard input for filling body using VBScript
.webedit("name:=subj").click
Set wsho=createobject("wscript.shell")
Wsho.sendkeys ("{TAB}")
Wsho.sendkeys ("{TAB}")
Wsho.sendkeys (B)
'Keyboard automation completed
.webbutton("name:=send", "index:=0").click
End with
End with
'Do logout using QTPscript in DP
With browser("title:=.*")
With.page("title:=.*")
.link("name:=Sign Out").click
End with
End with
'Close Yahoo website using QTPscript in DP
Browser("title:=.*").close
next
'Close excel application
exo.Quit
Please find the below progam for sending number of mails at one go using QTP Tool, VBscript Discriptive Language, and Excel Document....Hope you will enjoy this :-)
NOTE: Object Properties may change based on browser versions and OS
Option explicit
Dim bro, url, wsho, exo, wbo, wso, nor, i, T, C, B, F
'open excel file sheet using VBScript
'Bro for browser
'url for website
'wsho for keyboard object
'exo for excel application
'wbo for excel work book
'wso for excel work sheet
'nor for number of rows count
'i for looping
'T for to addresses from excel sheet
'C for CC addresses from excel sheet
'B for mail body from excel sheet
'F for file path from excel sheet
Set exo=createobject ("Excel.application")
exo.visible=true
set wbo=exo.workbooks.open ("C:\Documents and Settings\qa\Desktop\QTP Practice\PATH FILES\email list.xls")
set wso=wbo.worksheets("sheet1")
nor=wso.usedrange.rows.count
for i = 2 to nor step 1 '(2 is used because first row is given for headings)
T=wso.cells (i, 1)
C=wso.cells (i, 2)
B=wso.cells (i, 3)
F=wso.cells (i, 4)
'Launch Yahoomail website using VBscript
Bro= "C:\Program Files\Internet Explorer\iexplore.exe"
url= "http://www.yahoomail.com"
invokeapplication (bro&" "&url)
'Do login using QTPscript in DPWith browser ("title:=.*")
With.page ("title:=.*")
.webedit ("name:=login").set "prasadxxxxx"
.webedit ("name:=passwd").setsecure "52e8ddowlf543cb5ec81f6e705d2ec5edc6f617883501c0445045f623"
.webbutton("name:=Sign In").click
End with
End with
With browser ("title:=.*")
With.page ("title:=.*")
'Using analog i have avoided a dailogboxWindow("Microsoft Internet Explorer").RunAnalog "Track1"
end with
end with
'Go to compose a new message using QTPscript with DP
With browser ("title:=.*")
With.page ("title:=.*")
.webbutton("name:=Compose", "index:=0").click
End with
End with
'Fill mail compose page using QTPscript with DP
With browser ("title:=.*")
With.page ("title:=.*")
.webedit("name:=to").set T
.webedit("name:=cc").set C
.webedit("name:=subj").set "QTP Automation Tool"
.webbutton("name:=Attach Files").Click
end with
end with
With browser ("title:=.*")
With.page ("title:=.*")
.webfile("name:=uploadfile").set F
.webbutton("name:=Attach Files").Click
end with
end with
With browser ("title:=.*")
With.page ("title:=.*")
'Automate Keyboard input for filling body using VBScript
.webedit("name:=subj").click
Set wsho=createobject("wscript.shell")
Wsho.sendkeys ("{TAB}")
Wsho.sendkeys ("{TAB}")
Wsho.sendkeys (B)
'Keyboard automation completed
.webbutton("name:=send", "index:=0").click
End with
End with
'Do logout using QTPscript in DP
With browser("title:=.*")
With.page("title:=.*")
.link("name:=Sign Out").click
End with
End with
'Close Yahoo website using QTPscript in DP
Browser("title:=.*").close
next
'Close excel application
exo.Quit
No comments:
Post a Comment