{"id":949,"date":"2011-12-26T00:07:53","date_gmt":"2011-12-25T18:37:53","guid":{"rendered":"http:\/\/www.automationrepository.com\/?p=949"},"modified":"2011-12-26T00:08:34","modified_gmt":"2011-12-25T18:38:34","slug":"part-1-automating-outlook-using-qtp-general-introduction","status":"publish","type":"post","link":"https:\/\/www.automationrepository.com\/wordpress\/2011\/12\/part-1-automating-outlook-using-qtp-general-introduction\/","title":{"rendered":"Part 1: Automating Outlook using QTP | General Introduction"},"content":{"rendered":"<div style=\"text-align: justify; font-family: Verdana;\">\n<p><em>From today, we are starting off a series of articles on how to automate Microsoft Outlook using QTP. In these articles, we&#8217;ll try to cover the important and frequently used functionalities of MS Outlook. In this first article, we will start with the basics of Outlook automation and later would move on to more specific\/advanced <!--more-->topics.<\/em><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" title=\"Automating MS Outlook using QTP\" src=\"https:\/\/www.automationrepository.com\/wordpress\/wp-content\/uploads\/ar\/automating-ms-outlook-using-qtp-banner.png\" alt=\"Automating MS Outlook using QTP\" width=\"429\" height=\"110\" \/><\/p>\n<p><span><br \/>\n<\/span><\/p>\n<h3>How to begin automating MS Outlook?<\/h3>\n<p>Now the first question that might come to your mind is &#8211; <strong>How do you actually start with the automation of MS Outlook?<\/strong> Now we all know that MS Outlook is an application\/software that provides many functionalities such as sending &amp; receiving emails, managing your tasks, calender, contacts and many other things.<\/p>\n<p>MS Outlook also provides a set of classes and interfaces using which you can perform the above mentioned Outlook tasks through code without directly doing it manually in Outlook. So all you have to do is write some code that will first access the classes and interfaces exposed by MS Outlook. Once this is done, you would have access to all the methods and properties using which you can perform various Outlook tasks such as sending mails, creating new folders, distribution lists etc. <strong>This set of classes &amp; interfaces is collectively called the Outlook Object Model.<\/strong><\/p>\n<p><span style=\"text-decoration: underline;\"><br \/>\nLet us now create a sample script in QTP that would access the Outlook Object Model and use it to open Outlook and display the Inbox folder.<\/span> In the Outlook Object Model,<strong> &#8216;Application&#8217; Object is the topmost or parent Object that represents the entire Outlook Application<\/strong>. So we&#8217;ll first create an instance of <strong>Outlook.Application<\/strong> object.<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\nSet objOutlook = CreateObject(&quot;Outlook.Application&quot;)\r\n<\/pre>\n<p><span><br \/>\nOnce this is done, we&#8217;ll then use <strong>GetNamespace<\/strong> method to bind to the <strong>MAPI<\/strong> <strong> <\/strong>namespace.<\/span><\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\nSet objNameSpace = objOutlook.GetNamespace(&quot;MAPI&quot;)\r\n<\/pre>\n<p><span><br \/>\nNext, we have to create a reference to the inbox folder and then display it. This can be done using the below lines of code &#8211;<\/span><\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\nConst olFolderInbox = 6  'Inbox folder in Outlook is referenced through value 6\r\nSet objFolder = objNameSpace.GetDefaultFolder(olFolderInbox)\r\nobjFolder.Display\r\n<\/pre>\n<p><em><\/em><span><br \/>\nYou can also play around with other properties and methods of the Application object. <em>[To view the entire list of properties and methods available with the application object, you can refer the Outlook Object Model Documentation from MSDN Library.]<\/em><br \/>\n<\/span><\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\n'Check the total number of reminders available\r\nSet objAllReminders = objOutlook.Reminders\r\nmsgbox objAllReminders.Count\r\n'Check the version of the Outlook installed\r\nmsgbox  objOutlook.Version\r\n'Check the Product Code - Microsoft Outlook globally unique identifier (GUID).\r\nmsgbox  objOutlook.ProductCode\r\n'Close MS Outlook\r\nobjOutlook.Quit()\r\n<\/pre>\n<p><span><br \/>\nTo make the code more robust, you can first check if outlook is already open or not, and open Outlook only if it is not already open. Let&#8217;s see the full code for the same.<\/span><br \/>\n<strong>Sample Code 1: How to Open &amp; Close Outlook using QTP<\/strong><\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\n'Check if outlook is already open\r\nstrComputer = &quot;.&quot;\r\nSet objWMIService = GetObject(&quot;winmgmts:\\\\&quot; &amp; strComputer &amp; &quot;\\root\\cimv2&quot;)\r\nSet objTaskMgrProc = objWMIService.ExecQuery(&quot;SELECT * FROM Win32_Process WHERE Name = 'outlook.exe'&quot;)\r\n\r\n'If outlook is not open, then open it\r\nIf objTaskMgrProc.Count = 0 Then\r\nSet objOutlook = CreateObject(&quot;Outlook.Application&quot;)\r\nSet objNameSpace = objOutlook.GetNamespace(&quot;MAPI&quot;)\r\nSet objFolder = objNameSpace.GetDefaultFolder(6)\r\nobjFolder.Display\r\n'Check the total number of reminders available\r\nSet objAllReminders = objOutlook.Reminders\r\nmsgbox objAllReminders.Count\r\n'Close Outlook\r\nobjOutlook.Quit()\r\nElse\r\nmsgbox &quot;Outlook already open&quot;\r\nEnd If\r\n<\/pre>\n<p><span><br \/>\nThis article is just the beginning where you have seen how to open and close Outlook using QTP. In the upcoming articles, we&#8217;ll explore more specific topics in details such as &#8211;<\/span><\/p>\n<ul>\n<li><strong>..<\/strong> How to create &amp; send emails, attach files to emails, retrieve unread mails from Inbox etc.<\/li>\n<li><strong>..<\/strong> How to access Outlook Contacts, add\/delete contacts &amp; search for specific contacts.<\/li>\n<li><strong>..<\/strong> How to work with Outlook folders, Calender Items, Appointments etc.<\/li>\n<\/ul>\n<\/div>\n<p><span><br \/>\n<\/span><\/p>\n<div style=\"font-family: Verdana,sans-serif; border: 1px solid #C8B560; padding: 3mm; background: #FFF8C6; text-align: center;\">\n<p>If you liked this article, you can join our blog to get new articles delivered directly in your inbox.<\/p>\n<form style=\"text-align: center;\" action=\"http:\/\/feedburner.google.com\/fb\/a\/mailverify\" method=\"post\" onsubmit=\"window.open('http:\/\/feedburner.google.com\/fb\/a\/mailverify?uri=automationrepository\/feeds', 'popupwindow', 'scrollbars=yes,width=550,height=520');return true\" target=\"popupwindow\"><input style=\"width: 160px; height: 20px;\" onfocus=\"if (this.value == 'Enter Your Email Address') {this.value = '';}\" onblur=\"if (this.value == '') {this.value = 'Enter Your Email Address';}\" type=\"text\" value=\"Enter Your Email Address\" \/> <input type=\"hidden\" name=\"uri\" value=\"automationrepository\/feeds\" \/> <input type=\"hidden\" name=\"loc\" value=\"en_US\" \/> <input type=\"submit\" value=\"Join Us\" \/><\/p>\n<p style=\"text-align: justify;\">\n<\/form>\n<\/div>\n<p><span><br \/>\n<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>From today, we are starting off a series of articles on how to automate Microsoft Outlook using QTP. In these articles, we&#8217;ll try to cover the important and frequently used functionalities of MS Outlook. In this first article, we will start with the basics of Outlook automation and later would move on to more specific\/advanced<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,9],"tags":[54],"class_list":["post-949","post","type-post","status-publish","format-standard","hentry","category-advanced-concepts","category-qtp-concepts","tag-automating-outlook-using-qtp"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Part 1: Automating Outlook using QTP | General Introduction - XX<\/title>\n<meta name=\"description\" content=\"Automating Outlook using QTP | General Introduction - Part 1. Here you&#039;ll see how you can open &amp; close MS Outlook using QTP.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.automationrepository.com\/wordpress\/2011\/12\/part-1-automating-outlook-using-qtp-general-introduction\/\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Anish Pillai\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/2011\/12\/part-1-automating-outlook-using-qtp-general-introduction\/\",\"url\":\"https:\/\/www.automationrepository.com\/wordpress\/2011\/12\/part-1-automating-outlook-using-qtp-general-introduction\/\",\"name\":\"Part 1: Automating Outlook using QTP | General Introduction - XX\",\"isPartOf\":{\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/2011\/12\/part-1-automating-outlook-using-qtp-general-introduction\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/2011\/12\/part-1-automating-outlook-using-qtp-general-introduction\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.automationrepository.com\/wordpress\/wp-content\/uploads\/ar\/automating-ms-outlook-using-qtp-banner.png\",\"datePublished\":\"2011-12-25T18:37:53+00:00\",\"dateModified\":\"2011-12-25T18:38:34+00:00\",\"author\":{\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/#\/schema\/person\/7a35710e1ce89e5fb481be88fcd6cd20\"},\"description\":\"Automating Outlook using QTP | General Introduction - Part 1. Here you'll see how you can open & close MS Outlook using QTP.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/2011\/12\/part-1-automating-outlook-using-qtp-general-introduction\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.automationrepository.com\/wordpress\/2011\/12\/part-1-automating-outlook-using-qtp-general-introduction\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/2011\/12\/part-1-automating-outlook-using-qtp-general-introduction\/#primaryimage\",\"url\":\"https:\/\/www.automationrepository.com\/wordpress\/wp-content\/uploads\/ar\/automating-ms-outlook-using-qtp-banner.png\",\"contentUrl\":\"https:\/\/www.automationrepository.com\/wordpress\/wp-content\/uploads\/ar\/automating-ms-outlook-using-qtp-banner.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/2011\/12\/part-1-automating-outlook-using-qtp-general-introduction\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.automationrepository.com\/wordpress\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Part 1: Automating Outlook using QTP | General Introduction\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/#website\",\"url\":\"https:\/\/www.automationrepository.com\/wordpress\/\",\"name\":\"XX\",\"description\":\"\\r\\nasas\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.automationrepository.com\/wordpress\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/#\/schema\/person\/7a35710e1ce89e5fb481be88fcd6cd20\",\"name\":\"Anish Pillai\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/8aa984de2295c3c4078fa48f6ba5d91e7c849b1a27a11dca24c6f11dd673ba14?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/8aa984de2295c3c4078fa48f6ba5d91e7c849b1a27a11dca24c6f11dd673ba14?s=96&d=mm&r=g\",\"caption\":\"Anish Pillai\"},\"description\":\"Find more about Anish Pillai on Google+\",\"sameAs\":[\"http:\/\/www.automationrepository.com\"],\"url\":\"https:\/\/www.automationrepository.com\/wordpress\/author\/anish\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Part 1: Automating Outlook using QTP | General Introduction - XX","description":"Automating Outlook using QTP | General Introduction - Part 1. Here you'll see how you can open & close MS Outlook using QTP.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.automationrepository.com\/wordpress\/2011\/12\/part-1-automating-outlook-using-qtp-general-introduction\/","twitter_misc":{"Written by":"Anish Pillai","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.automationrepository.com\/wordpress\/2011\/12\/part-1-automating-outlook-using-qtp-general-introduction\/","url":"https:\/\/www.automationrepository.com\/wordpress\/2011\/12\/part-1-automating-outlook-using-qtp-general-introduction\/","name":"Part 1: Automating Outlook using QTP | General Introduction - XX","isPartOf":{"@id":"https:\/\/www.automationrepository.com\/wordpress\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.automationrepository.com\/wordpress\/2011\/12\/part-1-automating-outlook-using-qtp-general-introduction\/#primaryimage"},"image":{"@id":"https:\/\/www.automationrepository.com\/wordpress\/2011\/12\/part-1-automating-outlook-using-qtp-general-introduction\/#primaryimage"},"thumbnailUrl":"https:\/\/www.automationrepository.com\/wordpress\/wp-content\/uploads\/ar\/automating-ms-outlook-using-qtp-banner.png","datePublished":"2011-12-25T18:37:53+00:00","dateModified":"2011-12-25T18:38:34+00:00","author":{"@id":"https:\/\/www.automationrepository.com\/wordpress\/#\/schema\/person\/7a35710e1ce89e5fb481be88fcd6cd20"},"description":"Automating Outlook using QTP | General Introduction - Part 1. Here you'll see how you can open & close MS Outlook using QTP.","breadcrumb":{"@id":"https:\/\/www.automationrepository.com\/wordpress\/2011\/12\/part-1-automating-outlook-using-qtp-general-introduction\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.automationrepository.com\/wordpress\/2011\/12\/part-1-automating-outlook-using-qtp-general-introduction\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.automationrepository.com\/wordpress\/2011\/12\/part-1-automating-outlook-using-qtp-general-introduction\/#primaryimage","url":"https:\/\/www.automationrepository.com\/wordpress\/wp-content\/uploads\/ar\/automating-ms-outlook-using-qtp-banner.png","contentUrl":"https:\/\/www.automationrepository.com\/wordpress\/wp-content\/uploads\/ar\/automating-ms-outlook-using-qtp-banner.png"},{"@type":"BreadcrumbList","@id":"https:\/\/www.automationrepository.com\/wordpress\/2011\/12\/part-1-automating-outlook-using-qtp-general-introduction\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.automationrepository.com\/wordpress\/"},{"@type":"ListItem","position":2,"name":"Part 1: Automating Outlook using QTP | General Introduction"}]},{"@type":"WebSite","@id":"https:\/\/www.automationrepository.com\/wordpress\/#website","url":"https:\/\/www.automationrepository.com\/wordpress\/","name":"XX","description":"\r\nasas","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.automationrepository.com\/wordpress\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.automationrepository.com\/wordpress\/#\/schema\/person\/7a35710e1ce89e5fb481be88fcd6cd20","name":"Anish Pillai","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.automationrepository.com\/wordpress\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/8aa984de2295c3c4078fa48f6ba5d91e7c849b1a27a11dca24c6f11dd673ba14?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/8aa984de2295c3c4078fa48f6ba5d91e7c849b1a27a11dca24c6f11dd673ba14?s=96&d=mm&r=g","caption":"Anish Pillai"},"description":"Find more about Anish Pillai on Google+","sameAs":["http:\/\/www.automationrepository.com"],"url":"https:\/\/www.automationrepository.com\/wordpress\/author\/anish\/"}]}},"_links":{"self":[{"href":"https:\/\/www.automationrepository.com\/wordpress\/wp-json\/wp\/v2\/posts\/949","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.automationrepository.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.automationrepository.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.automationrepository.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.automationrepository.com\/wordpress\/wp-json\/wp\/v2\/comments?post=949"}],"version-history":[{"count":10,"href":"https:\/\/www.automationrepository.com\/wordpress\/wp-json\/wp\/v2\/posts\/949\/revisions"}],"predecessor-version":[{"id":960,"href":"https:\/\/www.automationrepository.com\/wordpress\/wp-json\/wp\/v2\/posts\/949\/revisions\/960"}],"wp:attachment":[{"href":"https:\/\/www.automationrepository.com\/wordpress\/wp-json\/wp\/v2\/media?parent=949"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.automationrepository.com\/wordpress\/wp-json\/wp\/v2\/categories?post=949"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.automationrepository.com\/wordpress\/wp-json\/wp\/v2\/tags?post=949"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}