PhillipWoodson Posted March 27, 2012 Share Posted March 27, 2012 I am trying to write a script to access a public folder in outlook and open an item and execute it. I am using the OutlookEX UDF. I can't for the life of me figure out how to make it work. Do you have any examples showing how to use the _OL_FolderAccess and _OL_ItemFind functions. Also once i find the item thats in the folder I want to open it and execute a button that runs an export process on this page. I am a newbie to this and would greatly appreciate a working example. Thanks. P Link to comment Share on other sites More sharing options...
water Posted March 27, 2012 Share Posted March 27, 2012 Use $oOutlook = _OL_Open() $aFolder = _OL_FolderAccess($oOutlook, "rootfolder\subfolder\...\subfolder")to access the public folder. Remember that _OL_FolderAccess returns an array so use$aResult = _OL_ItemFind($oOutlook, $aFolder[1], ....) My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
PhillipWoodson Posted March 28, 2012 Author Share Posted March 28, 2012 Thank you for the code example, that helped. Once i have the Item in the list what command would i use to open the item? $aResult.Open ? Thanks Link to comment Share on other sites More sharing options...
water Posted March 29, 2012 Share Posted March 29, 2012 With "to open the item" do you mean to display the item or do you want to access the properties of the item by your script? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
PhillipWoodson Posted March 29, 2012 Author Share Posted March 29, 2012 I want to open the item and press a button on it to execute it. Link to comment Share on other sites More sharing options...
water Posted March 29, 2012 Share Posted March 29, 2012 "The item" is it an Outlook "default" item like appointment or mail or a user defined form or something similar? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
PhillipWoodson Posted March 29, 2012 Author Share Posted March 29, 2012 Its a mail item that has code behind it and button on the front. When executed it performs an export of Data using an odbc driver. The item stays in the folder and gets executed manually when needed. Link to comment Share on other sites More sharing options...
water Posted March 29, 2012 Share Posted March 29, 2012 (edited) This should display the item: #include <OutlookEx.au3> $oOutlook = _OL_Open() $aFolder = _OL_FolderAccess($oOutlook, "rootfoldersubfolder...subfolder") $aResult = _OL_ItemFind($oOutlook, $aFolder[1], $olMailItem, "[Subject]='Test'", "", "", "EntryID") _OL_ItemDisplay($oOutlook, $aResult[1][0]) Displays the first item found with a subject of "Test" Edited March 29, 2012 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
PhillipWoodson Posted April 2, 2012 Author Share Posted April 2, 2012 This is the error i get. (52) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: _OL_ItemDisplay($oOutlook, $aItems[1][0]) _OL_ItemDisplay($oOutlook, ^ ERROR Here is my code. $aFolders = _OL_FolderAccess($oOutlook, "Public FoldersAll Public FoldersIT HELP DESKService RequestHelp DeskReports") $aItems = _OL_ItemFind($oOutlook, $aFolders[1], $olMailItem, "[subject]='Export Utility'","","","EntryID") _OL_ItemDisplay($oOutlook, $aItems[1][0]) _OL_Close($oOutlook) Any help would be appreciated. Link to comment Share on other sites More sharing options...
water Posted April 2, 2012 Share Posted April 2, 2012 Could you please try this code with extended error checking? #include <OutlookEx.au3> $oOutlook = _OL_Open() If @error Then Exit MsgBox(16, $sTitle, "Error returned by _OL_Open: " & @error & ", @extended: " & @extended) $aFolders = _OL_FolderAccess($oOutlook, "Public FoldersAll Public FoldersIT HELP DESKService RequestHelp DeskReports") If @error Then MsgBox(16, $sTitle, "Error returned by _OL_FolderAccess: " & @error & ", @extended: " & @extended) Else $aItems = _OL_ItemFind($oOutlook, $aFolders[1], $olMailItem, "[Subject]='Export Utility'", "", "", "EntryID") If @error Then MsgBox(16, $sTitle, "Error returned by _OL_ItemFind: " & @error & ", @extended: " & @extended) ElseIf $aItems[0][0] = 0 Then MsgBox(16, $sTitle, "No mail items found!") Else _OL_ItemDisplay($oOutlook, $aItems[1][0]) EndIf EndIf _OL_Close($oOutlook) My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
PhillipWoodson Posted April 2, 2012 Author Share Posted April 2, 2012 It returned the message No Mail Items Found. So its a different item type. Link to comment Share on other sites More sharing options...
water Posted April 2, 2012 Share Posted April 2, 2012 (edited) Then put a ";" in front of lineIf $oOL_Item.Class <> $iOL_ObjectClass Then ContinueLoopin function _OL_ItemFind so the class is ignored. And then please run this modified version #include <OutlookEx.au3> $oOutlook = _OL_Open() If @error Then Exit MsgBox(16, $sTitle, "Error returned by _OL_Open: " & @error & ", @extended: " & @extended) $aFolders = _OL_FolderAccess($oOutlook, "Public FoldersAll Public FoldersIT HELP DESKService RequestHelp DeskReports") If @error Then MsgBox(16, $sTitle, "Error returned by _OL_FolderAccess: " & @error & ", @extended: " & @extended) Else $aItems = _OL_ItemFind($oOutlook, $aFolders[1], $olMailItem, "[Subject]='Export Utility'", "", "", "EntryID,Class") If @error Then MsgBox(16, $sTitle, "Error returned by _OL_ItemFind: " & @error & ", @extended: " & @extended) ElseIf $aItems[0][0] = 0 Then MsgBox(16, $sTitle, "No mail items found!") Else _ArrayDisplay($aItems) _OL_ItemDisplay($oOutlook, $aItems[1][0]) EndIf EndIf _OL_Close($oOutlook) We can then check the displayed array. Edited April 2, 2012 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
PhillipWoodson Posted April 2, 2012 Author Share Posted April 2, 2012 I am not sure i understand what you are telling me to do. This line is not in the code you provided. Do i need to add this code ? If $oOL_Item.Class <> $iOL_ObjectClass Then ContinueLoop Link to comment Share on other sites More sharing options...
water Posted April 2, 2012 Share Posted April 2, 2012 This line is in the UDF function _OL_ItemFind. It checks for the specified class and if equal the item is ignored. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
PhillipWoodson Posted April 2, 2012 Author Share Posted April 2, 2012 That worked. I got an error message stating that the export utility can only be opened by a named seat but thats a lot farther along. Link to comment Share on other sites More sharing options...
water Posted April 2, 2012 Share Posted April 2, 2012 Can you tell me what you get in the _ArrayDisplay? First column is the EntryID of the item, and the second is the objectclass. That's the interesting value. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
PhillipWoodson Posted April 2, 2012 Author Share Posted April 2, 2012 Row | Col 0 | Col 1 [0] | 1 | 2 [1] | 000000001A447390AA6611CD9BC800AA002FC45A0900834E9F82BA4B124688452249785E1F8A0246FD8B67150000834E9F82BA4B124688452249785E1F8A0246FD8C54040000 | 43 Link to comment Share on other sites More sharing options...
water Posted April 2, 2012 Share Posted April 2, 2012 I see. We used the wrong constant: It should be $olMail not $olMailitem My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
PhillipWoodson Posted April 2, 2012 Author Share Posted April 2, 2012 I changed it to the $olMail and still received the error message "Export utility can only be opened by a named seat". For some reason its not pickup up my mail profile for opening the item. Link to comment Share on other sites More sharing options...
water Posted April 2, 2012 Share Posted April 2, 2012 You manually click on the button and execute the code? The AutoIt script doesn't do anything you wouldn't do yourself. Does it work when you do it yourself? What does the code in the mail item do? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now