Yahoo Mail Automation Using Excel and Word
Option explicit
Dim exo, wbo, wso, nor, i, ieo, mswo, doco, pro, t, c, s, b, wsho
'exo for excel object
'wbo for work book object in excel
'wso for work sheet object in excel
'nor for number of rows in work sheet
'i for iteration or loop
'ieo for internet explorer object
'mswo for work object
'doco for document object in word
'pro for paragraph in document
't for to address from excel
'c for cc address from excel
's for subject from excel
'wsho for automating keyboard to send the keys through automation
'open existing excel file using VBScript Set exo= createobject("excel.application")
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
'open existing word document using VBScript Set Mswo= createobject("word.application")
Set Doco= mswo.documents.open("C:\Documents and Settings\qa\Desktop\QTP Practice\PATH FILES\Word Spellcheck.doc")
Set pro= doco.paragraphs
'launch yahoomail website using VBScript
Set ieo= createobject ("internetexplorer.application")
ieo.visible=true
ieo.navigate ("http://www.mail.yahoo.com")
'do login yahoo using QTPScript in DP
With browser ("title:=.*")
With.page ("title:=.*")
.webedit ("name:=login").set "prxxxxxxx"
.webedit ("name:=passwd").setsecure "52ea325bd89a05e9260dad8411922dfe344ae65a"
.webbutton("name:=Sign In").click
End with
End with
For i = 2 to nor step 1
T = wso.cells (i, 1)
C = wso.cells (i, 2)
S = wso.cells (i, 3)
B = pro (i-1).range.text 'i=2 in this loop for excel cells, i-1 loop is for word of first paragraph
'go to mail compose page using QTPScript in 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 S
'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)
Set wsho = nothing 'Keyboard automation completed and destroyed
.webbutton("name:=Send", "index:=0").click
Wait (5)
End with
End with
With browser ("title:=.*")
With.page ("title:=.*")
.link("name:=Back to Inbox").click
end with
end with
Next
'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 VBScript
ieo.quit
'Close excel software using VBScript
Exo.quit
'close msword software using VBScript
Doco=close (False) 'False is for closing the document without saving
Mswo.quit
Set pro=nothing
Set doco=nothing
Set mswo=nothing
Set wbo=nothing
Set exo=nothing
Set ieo=nothing
Option explicit
Dim exo, wbo, wso, nor, i, ieo, mswo, doco, pro, t, c, s, b, wsho
'exo for excel object
'wbo for work book object in excel
'wso for work sheet object in excel
'nor for number of rows in work sheet
'i for iteration or loop
'ieo for internet explorer object
'mswo for work object
'doco for document object in word
'pro for paragraph in document
't for to address from excel
'c for cc address from excel
's for subject from excel
'wsho for automating keyboard to send the keys through automation
'open existing excel file using VBScript Set exo= createobject("excel.application")
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
'open existing word document using VBScript Set Mswo= createobject("word.application")
Set Doco= mswo.documents.open("C:\Documents and Settings\qa\Desktop\QTP Practice\PATH FILES\Word Spellcheck.doc")
Set pro= doco.paragraphs
'launch yahoomail website using VBScript
Set ieo= createobject ("internetexplorer.application")
ieo.visible=true
ieo.navigate ("http://www.mail.yahoo.com")
'do login yahoo using QTPScript in DP
With browser ("title:=.*")
With.page ("title:=.*")
.webedit ("name:=login").set "prxxxxxxx"
.webedit ("name:=passwd").setsecure "52ea325bd89a05e9260dad8411922dfe344ae65a"
.webbutton("name:=Sign In").click
End with
End with
For i = 2 to nor step 1
T = wso.cells (i, 1)
C = wso.cells (i, 2)
S = wso.cells (i, 3)
B = pro (i-1).range.text 'i=2 in this loop for excel cells, i-1 loop is for word of first paragraph
'go to mail compose page using QTPScript in 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 S
'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)
Set wsho = nothing 'Keyboard automation completed and destroyed
.webbutton("name:=Send", "index:=0").click
Wait (5)
End with
End with
With browser ("title:=.*")
With.page ("title:=.*")
.link("name:=Back to Inbox").click
end with
end with
Next
'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 VBScript
ieo.quit
'Close excel software using VBScript
Exo.quit
'close msword software using VBScript
Doco=close (False) 'False is for closing the document without saving
Mswo.quit
Set pro=nothing
Set doco=nothing
Set mswo=nothing
Set wbo=nothing
Set exo=nothing
Set ieo=nothing
No comments:
Post a Comment