Working with Outlook API using UFT? – User friendly Tech help
|Outlook object model|
The above mind map structure represents the flow of objects that we have used to work with outlook API model.
nIt is the parent object which represents the entire Microsoft Outlook application.
nWhen we use Automation to control Microsoft Outlook from another application (UFT in our case), we use the CreateObject method to create an Outlook Application object.
nYou can read the complete outlook object model, to learn more.
nSet objOutlook= CreateObject(“Outlook.Application”)
nThis object provides methods for logging in and out, accessing storage objects directly by ID, accessing certain special default folders directly, and accessing data sources owned by other users in outlook Application.
nWe have used GetNamespace (“MAPI”) method, to return the Outlook Namespace object from the Application object (objOutlook in our case).
nSyntax:-Set OutlookSetNameSpace = objOutlook.GetNamespace(Cstr(UCase(sNameSpace)))Note: – The only supported name space type is “MAPI” in Outlook
nMAPI: – The Messaging Application Programming Interface (MAPI) is a proprietary email protocol of Microsoft, that is used by Outlook (Microsoft’s email client software) to communicate with Microsoft Exchange (its email server software). Thus MAPI provides the messaging architecture for Microsoft Outlook, it provides a set of interfaces, functions, and other data types to facilitate working with outlook.
Folder object: –
nWe have used GetDefaultFolder(FolderType) method which Returns a Folder object that represents the default folder of the requested type.In our case FolderType = 6 , which refers the inbox folder.
nSet OutlookSetFolder = objNamespace.GetDefaultFolder(sFolder)
nProperties of Email: – Further we have accessed the Subject,To,CC,Body,… properties to fetch the required values.
'Creating the outlook Objects
'Opening the outlook connection
set objOutlook = OutlookOpenConnection()
'Creating the Namespace Mapi
Set objNameSpace = OutlookSetNameSpace(objOutlook, "MAPI")
'Referring to Inbox folder (VALUE = 6 , means Inbox folder)
'Reading the email and doing the required comparisons
if OutlookCheckUnreadEmails("Subject", "TestMail",3) then
Print "Run is Successfull"
Print "Run is Unsuccessfull"
'Destroying the Outlook objectOutlookCloseConnection(objOutlook)
Function for Outlook,
n1.Creating and Destroying Outlook object
|Creating/Destroying Outlook Object|
2.Referring the Outlook Namespace
n3.Pointing Outlook object to work with Inbox Foldern
|Referring the Folder in Outlook|
n4.Finding the match for given value of the Emailn
|Verify the Email|
5.Setting the Read/Unread Filter
|Set filter on Outlook Emails|
More Practical Scenarios