geoffnoakes Posted September 8, 2020 Posted September 8, 2020 Water, I've been using AutoIT and OutlookEX for about 10 years, and I thank you for creating that UDF. I'm using AutoIT3 on a PC running Windows 10 and Outlook 2016. I've been able to write scripts using OutlookEX which work with the the primary email account (i.e., the OST), but not with PSTs. Here is what I am trying to do, for hundreds of PSTs: 1. I want to access a PST, lookup a Contact in that PST (by what Outlook calls the FullName). 2. I want to copy that Contact into a different PST. I'm confused about use of (and interplay between) _OL_PSTAccess, _OL_ItemCopy, _OL_FolderTree, and maybe other functions. For the 2 steps above, may I ask you to send me some pseudocode that will help guide me? I am guessing that this will be no more that a handful of functions. All I need to know is the sequence of functions to use -- I am certain I'll be able to figure out what parameters to pass to each function and how to process whatever is returned from the function. Thanks... Geoff
water Posted September 8, 2020 Posted September 8, 2020 This thread explains how to use _OL_PSTAccess and _OL_FolderAccess etc. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
geoffnoakes Posted September 8, 2020 Author Posted September 8, 2020 Thanks Water. When I run this code: #include <Array.au3> #include <OutlookEX.au3> #Include <OutlookEX_Base.au3> ; base functions and constants uses by OutlookEX Global Const $PSTFileName = "F:\Outlook Backups\NewGroup1\NewGroup1-Source PSTs\From Done\20121231-EA.pst" $oOutlook = _OL_Open() If @error <> 0 Then Exit -1 $oPSTRoot = _OL_PSTAccess($oOutlook, $PSTFileName) If @error <> 0 Then Exit -2 $aFolder = _OL_FolderAccess($oOutlook, Default, $olFolderContacts) If @error <> 0 Then Exit -3 $aItems = _OL_ItemFind($oOutlook, $aFolder[1], $olFolderContacts, '[FullName] = "Arthur Landerholm"', '', '', 'EntryID', '', 1) ConsoleWrite ("#4 : OL_ItemFind: @Error=" & @Error & ", @Extended=" & @Extended & @CRLF) _ArrayDisplay ($aItems, "#4") ConsoleWrite (_ArrayToString ($aItems) & @CRLF) If @error <> 0 Then Exit -4 ; close the PST _OL_PSTClose ($oOutlook, $oPSTRoot) If @error <> 0 Then Exit -5 ; end this Outlook session _OL_Close($oOutlook) If @error <> 0 Then Exit -5 Exit 0 The Console only shows this: >"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Users\geoffrey_noakes\Documents\MySystem\Source\ExtractContacts\idea1.au3" #4 : OL_ItemFind: @Error=0, @Extended=0 0 >Exit code: 0 Time: 3.052 ... and the _ArrayDisplay of $aItems (from the call to OL_ItemFind) only has Row 0 (with a value of 0) -- see the screen shot. The script is not finding my contact (which I know is in the PST's Contact folder).
water Posted September 9, 2020 Posted September 9, 2020 You do not provide a store in _OL_FolderAccess, hence it accesses your primary store. Use something like this as described in the thread I linked you to in the above post. $oPSTRoot = _OL_PSTAccess($oOutlook, $PSTFileName, "EA") $aFolder = _OL_FolderAccess($oOutlook, "EA", $olFolderContacts) My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
geoffnoakes Posted September 10, 2020 Author Posted September 10, 2020 Thanks Water, that helped. My modified code is this: #include <Array.au3> #include <OutlookEX.au3> #Include <OutlookEX_Base.au3> ; base functions and constants uses by OutlookEX Global Const $SourcePSTFileName = @DesktopDir & "\Test-20121231-EA.pst" Global Const $SourcePSTDisplayName = "Test-20121231-EA" $oOutlook = _OL_Open () $aSourceFolder = _OL_FolderAccess ($oOutlook, $SourcePSTDisplayName, $olFolderContacts) $aSourceTree = _OL_FolderTree ($oOutlook, $aSourceFolder [1]) _ArrayDisplay ($aSourceTree) For $i = 0 to UBound ($aSourceTree) - 1 ConsoleWrite (@Tab & $i & @Tab & $aSourceTree [$i] & @CRLF) Next $aSourceItems = _OL_ItemFind ($oOutlook, $aSourceFolder [1], Default, '[FullName] = "Arthur Landerholm"', '', '', 'EntryID', '', 0) If @Error = 0 Then ConsoleWrite ("Items found..." & @CRLF) _ArrayDisplay ($aSourceItems, "_OL_ItemFind array") ConsoleWrite (_ArrayToString ($aSourceItems) & @CRLF) Else ConsoleWrite ("_OL_ItemFind: @Error=" & @Error & ", @Extended=" & @Extended & @CRLF) Exit 4 EndIf _OL_Close ($oOutlook) Exit 0 The console results are: >"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Users\geoffrey_noakes\Documents\MySystem\Source\ExtractContacts\Question2.au3" 0 \\Test-20121231-EA 1 \\Test-20121231-EA\Deleted Items 2 \\Test-20121231-EA\Contacts 3 \\Test-20121231-EA\Drafts _OL_ItemFind: @Error=5, @Extended=-2147352567 >Exit code: 4 Time: 59.87 I used the Outlook client for the first screen shot -- it shows the PST in question and the Contact in question, and the second screen shot is after the _OL_FolderAccess command -- so my script idefinitely accessing the correct PST. But after the _OL_ItemFind command, I get an @Error of 5 ("Error filtering items. @extended is set to the COM error") and an @Extended value of -2147352567. What am I doing wrong here? Thanks... Geoff
water Posted September 10, 2020 Posted September 10, 2020 I had to change two things: _OL_FolderAccess needs the full path to the folder (I need to investigate why this only works for the "primary" store) _OL_ItemFind needs the FullName in reverse order: Lastname Firstname #include <Array.au3> #include <OutlookEX.au3> ; #Include <OutlookEX_Base.au3> ==> No need to include. Gets included by OutlookEX.au3 Global Const $SourcePSTDisplayName = "Test" Global Const $SourceContactsFolderName = "Test-Contacts" $oOutlook = _OL_Open () If @error Then Exit ConsoleWrite("_OL_Open: @error: " & @error & ", @extended: " & @extended & @CRLF) $aSourceFolder = _OL_FolderAccess ($oOutlook, $SourcePSTDisplayName & "\" & $SourceContactsFolderName) If @error Then Exit ConsoleWrite("_OL_FolderAccess: @error: " & @error & ", @extended: " & @extended & @CRLF) $aSourceTree = _OL_FolderTree ($oOutlook, $aSourceFolder [1]) If @error Then Exit ConsoleWrite("_OL_FolderTree: @error: " & @error & ", @extended: " & @extended & @CRLF) _ArrayDisplay ($aSourceTree) $aSourceItems = _OL_ItemFind ($oOutlook, $aSourceFolder [1], Default, '[FullName] = "Doe John"', '', '', "EntryID,FullName", '', 0) If @Error = 0 Then _ArrayDisplay ($aSourceItems, "_OL_ItemFind array") Else ConsoleWrite ("_OL_ItemFind: @Error=" & @Error & ", @Extended=" & @Extended & @CRLF) EndIf _OL_Close ($oOutlook) My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
geoffnoakes Posted September 11, 2020 Author Posted September 11, 2020 Water, that worked great, thanks very much. I've also discovered the OutlookTools UDF -- I'm learning about it now. Many thanks... Geoff
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