HighlanderSword Posted January 21, 2017 Posted January 21, 2017 Hello, I'm attempting to get the Store id and the Entry id of various Search folders in Outlook 2013. I'm able to manually get them by selecting them and the running the code below and I get the result of \\Paul Schrader 2012\search folders\Mail to Read When I change the _ol_folderget to _OL_FolderGet($oOutlook,"\\Paul Schrader 2012\search folders\Mail to Read") _OL_FolderGet($oOutlook,"Paul Schrader 2012\search folders\Mail to Read") _OL_FolderGet($oOutlook,"Paul Schrader 2012\search folders\Mail to Read\") I get error messages of @error=1 and extended = 4. I need to get this information for over 400 Search folders. What am I missing ? #include <OutlookEX.au3> Global $oOutlook = _OL_Open() Global $SrchFolder = _OL_FolderGet($oOutlook) _ArrayDisplay($Srchfolder)
water Posted January 21, 2017 Posted January 21, 2017 (edited) The UDF does not support search folders. You need to use something like this: #include <OutlookEX.au3> Global $oOL = _OL_Open() Global $oNamespace = $oOL.GetNamespace("MAPI") Global $oDefaultStore = $oNamespace.DefaultStore Global $oSearchFolders = $oDefaultStore.GetSearchFolders Global $oSearchFolder = $oSearchFolders("Mail to Read") ;------------------------------------- ; Get all mails from the search folder ;------------------------------------- Global $aItems = _OL_ItemFind($oOL, $oSearchFolder, $olMail, "", "", "", "Subject,Body") _ArrayDisplay($aItems, "Unread mails") Edited January 21, 2017 by water 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
HighlanderSword Posted January 24, 2017 Author Posted January 24, 2017 Thank, The information you provided worked
water Posted January 24, 2017 Posted January 24, 2017 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
Murenuchi Posted December 11, 2017 Posted December 11, 2017 Hello, I'm trying to get the email count from 3 search folders (on 3 different mailboxes). I'm still really new to this, so I figured that if I repeat the steps for each mailbox, I would get 3 different results. Here's my code: expandcollapse popupGlobal $oOL = _OL_Open() Global $oNamespace = $oOL.GetNamespace("MAPI") Global $oDefaultStore = $oNamespace.DefaultStore ; Access the default store Global $oSearchFolders = $oDefaultStore.GetSearchFolders ; Access the collection of search folders Global $oSearchFolder = $oSearchFolders("Unreplied") ; Access the search folder named "Mail to Read" ;------------------------------------- ; Get all mails from the search folder1 ;------------------------------------- Global $aItems = _OL_ItemFind($oOL, $oSearchFolder, $olMail, "", "", "", "Subject,Body") _ArrayDisplay($aItems, "Unreplied mails") Global $oOL2 = _OL_Open() Global $oNamespace2 = $oOL2.GetNamespace("MAPI") Global $oDefaultStore2 = $oNamespace2.DefaultStore ; Access the default store Global $oSearchFolders2 = $oDefaultStore2.GetSearchFolders ; Access the collection of search folders Global $oSearchFolder2 = $oSearchFolders2("Unreplied2") ; Access the search folder named "Mail to Read" ;------------------------------------- ; Get all mails from the search folder2 ;------------------------------------- Global $aItems2 = _OL_ItemFind($oOL2, $oSearchFolder2, $olMail, "", "", "", "Subject,Body") _ArrayDisplay($aItems2, "Unreplied mails") Global $oOL3 = _OL_Open() Global $oNamespace3 = $oOL3.GetNamespace("MAPI") Global $oDefaultStore3 = $oNamespace3.DefaultStore ; Access the default store Global $oSearchFolders3 = $oDefaultStore3.GetSearchFolders ; Access the collection of search folders Global $oSearchFolder3 = $oSearchFolders3("Unreplied3") ; Access the search folder named "Mail to Read" ;------------------------------------- ; Get all mails from the search folder2 ;------------------------------------- Global $aItems3 = _OL_ItemFind($oOL3, $oSearchFolder3, $olMail, "", "", "", "Subject,Body") _ArrayDisplay($aItems3, "Unreplied mails") The first one comes up ok. But the rest won't display the results. Is there another way of doing this? Thanks in advance!!
water Posted December 11, 2017 Posted December 11, 2017 You do not need to multiply the whole code. This stripped down version should do the trick as well (untested): #include <OutlookEX.au3> Global $oOL = _OL_Open() Global $oNamespace = $oOL.GetNamespace("MAPI") Global $oDefaultStore = $oNamespace.DefaultStore ; Access the default store Global $oSearchFolders = $oDefaultStore.GetSearchFolders ; Access the collection of search folders Global $oSearchFolder1 = $oSearchFolders("Unreplied") ; Access the search folder named "Mail to Read" ;------------------------------------- ; Get all mails from the search folder1 ;------------------------------------- Global $aItems = _OL_ItemFind($oOL, $oSearchFolder1, $olMail, "", "", "", "Subject,Body") _ArrayDisplay($aItems, "Unreplied mails") ; Global $oOL2 = _OL_Open() ; Global $oNamespace2 = $oOL2.GetNamespace("MAPI") ; Global $oDefaultStore2 = $oNamespace2.DefaultStore ; Access the default store ; Global $oSearchFolders2 = $oDefaultStore2.GetSearchFolders ; Access the collection of search folders Global $oSearchFolder2 = $oSearchFolders("Unreplied2") ; Access the search folder named "Mail to Read" ;------------------------------------- ; Get all mails from the search folder2 ;------------------------------------- Global $aItems2 = _OL_ItemFind($oOL, $oSearchFolder2, $olMail, "", "", "", "Subject,Body") _ArrayDisplay($aItems2, "Unreplied mails") ; Global $oOL3 = _OL_Open() ; Global $oNamespace3 = $oOL3.GetNamespace("MAPI") ; Global $oDefaultStore3 = $oNamespace3.DefaultStore ; Access the default store ; Global $oSearchFolders3 = $oDefaultStore3.GetSearchFolders ; Access the collection of search folders Global $oSearchFolder3 = $oSearchFolders("Unreplied3") ; Access the search folder named "Mail to Read" ;------------------------------------- ; Get all mails from the search folder2 ;------------------------------------- Global $aItems3 = _OL_ItemFind($oOL, $oSearchFolder3, $olMail, "", "", "", "Subject,Body") _ArrayDisplay($aItems3, "Unreplied mails") 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
Murenuchi Posted December 11, 2017 Posted December 11, 2017 Thanks water! But it still doesn't show the results for the 2nd and 3rd search folders. I'm thinking I might have missed indicating the mailbox name? Not sure where to put it though.
water Posted December 11, 2017 Posted December 11, 2017 So you checking 3 search folders in 3 different stores (Mailboxes)? 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
Murenuchi Posted December 11, 2017 Posted December 11, 2017 yup! 3 search folders in 3 different mailboxes (1 search folder each mailbox).
water Posted December 11, 2017 Posted December 11, 2017 As a start. This little script lists all search folders in all accessed stores: #include <OutlookEX.au3> Global $oOL = _OL_Open() Global $oStores = $oOL.Session.Stores ConsoleWrite("Store count: " & $oStores.Count & @CRLF) For $i = 1 To $oStores.Count $oStore = $oStores($i) ConsoleWrite("Store " & $i & ": Displayname: " & $oStore.DisplayName & ", FilePath: " & $oStore.FilePath & @CRLF) $oSearchFolders = $oStore.GetSearchFolders For $oSearchFolder In $oSearchFolders ConsoleWrite(" SearchFolder: " & $oSearchFolder.FolderPath & @CRLF) Next Next 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
Moderators JLogan3o13 Posted December 11, 2017 Moderators Posted December 11, 2017 Not sure how this one stayed so long in the Examples forum. Moved to the appropriate forum. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Murenuchi Posted December 12, 2017 Posted December 12, 2017 18 hours ago, water said: As a start. This little script lists all search folders in all accessed stores: #include <OutlookEX.au3> Global $oOL = _OL_Open() Global $oStores = $oOL.Session.Stores ConsoleWrite("Store count: " & $oStores.Count & @CRLF) For $i = 1 To $oStores.Count $oStore = $oStores($i) ConsoleWrite("Store " & $i & ": Displayname: " & $oStore.DisplayName & ", FilePath: " & $oStore.FilePath & @CRLF) $oSearchFolders = $oStore.GetSearchFolders For $oSearchFolder In $oSearchFolders ConsoleWrite(" SearchFolder: " & $oSearchFolder.FolderPath & @CRLF) Next Next Thanks water! I'll play around with it for a while. I'll update you with the result.
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