{"id":855,"date":"2011-09-01T20:20:40","date_gmt":"2011-09-02T01:20:40","guid":{"rendered":"http:\/\/anvil-of-time.com\/wordpress\/?p=855"},"modified":"2021-03-10T20:45:28","modified_gmt":"2021-03-11T01:45:28","slug":"powerbuilder-reading-outlook-items","status":"publish","type":"post","link":"https:\/\/anvil-of-time.com\/powerbuilder\/powerbuilder-reading-outlook-items\/","title":{"rendered":"PowerBuilder &#8211; Reading Outlook Items"},"content":{"rendered":"<p>Here is some code which reads data from Outlook (2007 was tested) into PowerBuilder. You basically need to create a window with a multiline edit and a button on it. Put this into the clicked event of the button.<\/p>\n<p>To run it, open Outlook, select something (email message, task, etc.) then click the button on your window. There are many, many more methods and properties you have access to from PB via OLE to Outlook. The MSDN reference online is a big help<\/p>\n<pre name=\"code\" class=\"VB\">integer li_rc\nlong ll_itemcount, ll_i\noleobject lole_item, lole_outlook, lole_exp, lole_selecteditems\nstring ls_subject, ls_from, ls_to, ls_body, ls_msg\nlole_outlook = CREATE oleobject\nlole_exp = CREATE oleobject\nlole_selecteditems = CREATE oleobject\nli_rc = lole_outlook.ConnectToNewObject(&quot;outlook.application&quot;)\nlole_exp = lole_outlook.ActiveExplorer()\n\/\/ Outlook has to be running\nIf IsNull(lole_exp) THEN\n\tMessagebox(&#039;Outlook Error&#039;,&#039;Is Outlook currently running?&#039;)\n\tGOTO cleanup\nEND IF\nli_rc = lole_exp.class\n\/\/ caption is window name like &quot;Inbox - Microsoft Outlook&quot; or &quot;Calendar - Microsoft Outlook&quot;\nls_subject = lole_exp.caption\n\nlole_selecteditems = lole_exp.selection\nll_itemcount = lole_selecteditems.count\n\nFOR ll_i = 1 to ll_itemcount\n\tlole_item = CREATE oleobject\n\tlole_item = lole_exp.selection.item(ll_i)\n\tli_rc = lole_item.class\n\tCHOOSE CASE li_rc\n\t\tCASE 26 \/\/appointment\n\t\t\tls_body = lole_item.body\n\t\t\tls_msg += &#039;~r~n Appointment No: &#039; + string(ll_i) + &#039; of &#039; + string(ll_itemcount) + &#039;~r~n&#039; + ls_body\n\t\t\t\/\/ lots of other stuff could be here\n\t\tCASE 40 \/\/ contact\n\t\t\tls_body = lole_item.body\n\t\t\tls_msg += &#039;~r~n Contact No: &#039; + string(ll_i) + &#039; of &#039; + string(ll_itemcount) + &#039;~r~n&#039; + ls_body\n\t\t\t\n\t\tCASE 43 \/\/ mail\n\t\t\tls_subject = lole_item.subject\n\t\t\tls_from = lole_item.sendername\n\t\t\tls_to = lole_item.to\n\t\t\tls_body = lole_item.body\n\t\t\tls_msg = &#039;~r~nSubject: &#039; + ls_subject + &#039;~r~nFrom: &#039; + ls_from + &#039;~r~nTo: &#039; + ls_to + &#039;~r~nBody: &#039; + ls_body\n\t\t\tls_msg += &#039;~r~n Email No: &#039; + string(ll_i) + &#039; of &#039; + string(ll_itemcount) + &#039;~r~n&#039; + ls_msg\n\t\t\t\n\t\tCASE 48 \/\/ task\n\t\t\tls_subject = lole_item.subject\n\t\t\tls_to = lole_item.owner\n\t\t\tls_body = lole_item.body\n\t\t\tls_msg = &#039;~r~nSubject: &#039; + ls_subject + &#039;~r~nOwner: &#039; + ls_to + &#039;~r~nBody: &#039; + ls_body\n\t\t\tls_msg += &#039;~r~n Task No: &#039; + string(ll_i) + &#039; of &#039; + string(ll_itemcount) + &#039;~r~n&#039; + ls_msg\n\t\t\t\n\tEND CHOOSE\n\tDESTROY lole_item\nNEXT\nIF Len(ls_msg) &gt; 0 THEN\n\tmle_1.text = ls_msg\nELSE\n\tmle_1.text = &#039;No items processed.&#039;\nEND IF\ncleanup:\nDESTROY lole_selecteditems\nDESTROY lole_exp\nDESTROY lole_outlook<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Here is some code which reads data from Outlook (2007 was tested) into PowerBuilder. You basically need to create a window with a multiline edit and a button on it. Put this into the clicked event of the button. To run it, open Outlook, select something (email message, task, etc.) then click the button on&hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,10],"tags":[56,12,13,16],"_links":{"self":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts\/855"}],"collection":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/comments?post=855"}],"version-history":[{"count":5,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts\/855\/revisions"}],"predecessor-version":[{"id":1974,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts\/855\/revisions\/1974"}],"wp:attachment":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/media?parent=855"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/categories?post=855"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/tags?post=855"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}