Quick Test Professional does not have special support for the Outlook application, so there is no built-in method that will locate an e-mail and allow you to view the attachments.
However, Microsoft does have an Object Model for Outlook that can be used to automate many of the features.
You can refer to "Microsoft Outlook 2000 Object Model" for a complete listing of Outlook methods and properties that can be used within a Quick Test Professional (QTP) script.
How to open outlook from QTP
Set myOlApp = CreateObject("Outlook.Application")
‘to create an object
Set myNameSpace = myOlApp.GetNameSpace("QAT")
‘to create an name space
Set myFolder= myNameSpace.GetDefaultFolder(6)
‘to open inbox (inbox is the sixth folder)
myFolder.Display
How to show/display the total mails in inbox via QTP using Outlook methods?
Items.count - To display the total mails in the Inbox
Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("QAT")
Set myFolder= _
myNameSpace.GetDefaultFolder(6)
myFolder.Display
msgbox myfolder.items.count
How to send emails using QTP?
Set myOlApp = CreateObject("Outlook.Application")
‘ to create object for outlook
Set mail = myOlApp.CreateItem(0)
‘to click on the new message
mail.to = "admin@qatutorial.com“
‘to edit the mail id
mail.body = "Hi user, Welcome to QAT“
‘to edit the subject
mail.display
‘to display the outlook
mail.send
‘to send the mail
Displaying how many unread mails are there in QTP.
Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("QAT")
Set myFolder= myNameSpace.GetDefaultFolder(6)
myFolder.Display
msgbox myFolder.UnReadItemCount
‘for displaying how many items are unread till now