Sunblood Posted January 5, 2017 Share Posted January 5, 2017 (edited) I have 15+ shared mailboxes mapped to my Outlook, and I'm trying to get a list of all the unread emails (with received timestamp). I can get the Folder object for the mapped mailbox, but anything using ItemFind fails. The example UDF is able to find emails in the "Outlook-UDF-Test\SourceFolder\Mail" folder without any issue, but fails on (nearly) identical functions for mapped mailboxes. $oOutlook = _OL_Open() $folder = _OL_FolderAccess($oOutlook, "\\[[mailboxname]]\Inbox", $olFolderInbox) $aItems = _OL_ItemFind($oOutlook, $folder, $olMail) _ArrayDisplay($aitems) This just returns blank (no array window appears.) @error and @extended are both 0. There is one unread email in the folder. $folder has the full details for the mailbox and folder, it appears to be returning successfully. This is with Outlook 2016. _OL_ErrorNotify(2) returned this: Quote --------------------------- Outlook UDF - Debug Info --------------------------- COM Error Encountered in test.au3 OutlookEX UDF version = 1.2.2 @AutoItVersion = 3.3.12.0 @AutoItX64 = 0 @Compiled = 0 @OSArch = X64 @OSVersion = WIN_7 Scriptline = 1268 NumberHex = 80020009 Number = -2147352567 WinDescription = Exception occurred. Description = The attempted operation failed. An object could not be found. Source = Microsoft Outlook HelpFile = HelpContext = 0 LastDllError = 0 --------------------------- OK --------------------------- Edited January 5, 2017 by Sunblood Link to comment Share on other sites More sharing options...
water Posted January 6, 2017 Author Share Posted January 6, 2017 _OL_FolderAccess returns an array. So try: $oOutlook = _OL_Open() $aFolder = _OL_FolderAccess($oOutlook, "\\[[mailboxname]]\Inbox", $olFolderInbox) $aItems = _OL_ItemFind($oOutlook, $aFolder[1], $olMail) _ArrayDisplay($aItems) 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...
Sunblood Posted January 6, 2017 Share Posted January 6, 2017 12 hours ago, water said: _OL_FolderAccess returns an array. So try: $oOutlook = _OL_Open() $aFolder = _OL_FolderAccess($oOutlook, "\\[[mailboxname]]\Inbox", $olFolderInbox) $aItems = _OL_ItemFind($oOutlook, $aFolder[1], $olMail) _ArrayDisplay($aItems) Wow, yeah that went straight over my head. Working now, thanks! Link to comment Share on other sites More sharing options...
water Posted January 6, 2017 Author Share Posted January 6, 2017 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...
water Posted February 1, 2017 Author Share Posted February 1, 2017 Version 1.2.3.0 of the UDF has been released. Please test before using in production! For download please see my signature. 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...
HighlanderSword Posted February 5, 2017 Share Posted February 5, 2017 Any way to get the folder sizes of each folder in a PST FIle ? Link to comment Share on other sites More sharing options...
water Posted February 5, 2017 Author Share Posted February 5, 2017 There is no simple way. But this VB Script describes how to do it: http://www.xtremevbtalk.com/word-powerpoint-outlook-and-other-office-products/247972-outlook-folder-size-excel.html If you like a _OL_FolderSize function could be added to the OutllokEX UDF. 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...
alien4u Posted February 5, 2017 Share Posted February 5, 2017 @water my greetings... There is a way with the UDF to save individual emails with attachment as a .eml file? as the file you save when you drag an email to a Windows Explorer folder? I have some mailboxes with over 10000 emails and that is making Outlook perform slow as hell, I will like to save all the emails because our sales representatives use old emails for contacts and information they are not willing to delete the old emails... Regards Alien. Link to comment Share on other sites More sharing options...
water Posted February 5, 2017 Author Share Posted February 5, 2017 Outlook does not allow to save files in EML format. But maybe this freeware is what you are looking for?http://www.outlookfreeware.com/en/products/all/outlookmessagesexporteml/ 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...
HighlanderSword Posted February 6, 2017 Share Posted February 6, 2017 (edited) Any way to get the folder sizes of each folder in a PST FIle ? Would be great if you could add this to the UDF Edited February 6, 2017 by HighlanderSword Link to comment Share on other sites More sharing options...
water Posted February 6, 2017 Author Share Posted February 6, 2017 I played a bit with Outlook and noticed, that there might be a huge difference between the numbers you get from Outlook and the numbers returned by the script. Example: Outlook reports: 100036 KB The script reports: 99564 KB I know that Outlook stores a lot of hidden items in a folder - hence the difference. Would that be acceptable? 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...
HighlanderSword Posted February 6, 2017 Share Posted February 6, 2017 Yes that would work !!! Link to comment Share on other sites More sharing options...
water Posted February 6, 2017 Author Share Posted February 6, 2017 (edited) I have a quick and dirty prototype and I have to say: It is not very fast. Takes about 2 minutes to calculate the size of my mailbox. Size: 243 MB, items: 7750 Does this work for you? expandcollapse popup#include <OutlookEX.au3> Global $oOL = _OL_Open() $aFolder = _OL_FolderAccess($oOL, "*") ; Returns the size/number of items of your mailbox $aResult = _OL_FolderSize($oOL, $aFolder[1], True) ConsoleWrite("Folder size: " & $aResult[0] & @CRLF & "Item count: " & $aResult[1] & @CRLF) ; #FUNCTION# ==================================================================================================================== ; Name...........: _OL_FolderSize ; Description ...: Returns information about the size and number of items of a folder and subfolders. ; Syntax.........: _OL_FolderSize($oOL[, $vFolder = "*"[, $bRecursive = True]]) ; Parameters ....: $oOL - Outlook object returned by a preceding call to _OL_Open() ; $vFolder - Optional: Folder object as returned by _OL_FolderAccess or full name of folder (default = "*" = The root folder of the current user) ; $bRecursive - Optional: Calculates all subfolders of the specified folder as well (default = True) ; Return values .: Success - one-dimensional zero based array with the following information: ; |0 - Size of the specified folder/subfolders in Bytes ; |1 - Number of items in the specified folder/subfolders ; Failure - Returns "" and sets @error: ; |1 - Error accessing specified folder. See @extended for the error code of _OL_AccessFolder ; Author ........: water ; Modified.......: ; Remarks .......: The returned size might differ from what Outlook reports. That's because Outlook folders hold some hidden items ; which are invisible for the UDF. ;+ ; The function is not very fast as it has to query all items for its size. ; Related .......: ; Link ..........: ; Example .......: Yes ; =============================================================================================================================== Func _OL_FolderSize($oOL, $vFolder, $bRecursive = True) If Not IsObj($vFolder) Then If StringStripWS($vFolder, 3) = "" Then $vFolder = "*" Local $aTemp = _OL_FolderAccess($oOL, $vFolder) If @error Then Return SetError(1, @error, 0) $vFolder = $aTemp[1] EndIf Local $aResult[2] = [0, 0], $aTemp[2] ; Get size of all items in the specified folder For $oItem In $vFolder.Items $aResult[0] = $aResult[0] + $oItem.Size $aResult[1] = $aResult[1] + 1 Next ; Recursively calculate the size of all subfolders If $bRecursive Then For $vFolder In $vFolder.Folders $aTemp = _OL_FolderSize($vFolder, True) $aResult[0] = $aResult[0] + $aTemp[0] $aResult[1] = $aResult[1] + $aTemp[1] Next EndIf Return $aResult EndFunc ;==>_OL_FolderSize Edited February 6, 2017 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...
HighlanderSword Posted February 6, 2017 Share Posted February 6, 2017 Below is the error I got , I'm using outlookex version 1.2.1.0 (46) : ==> Subscript used on non-accessible variable.: $aResult[0] = $aResult[0] + $aTemp[0] $aResult[0] = $aResult[0] + $aTemp^ ERROR Link to comment Share on other sites More sharing options...
water Posted February 6, 2017 Author Share Posted February 6, 2017 That's a bug. Should be: Func _OL_FolderSize($oOL, $vFolder, $bRecursive = True) If Not IsObj($vFolder) Then If StringStripWS($vFolder, 3) = "" Then $vFolder = "*" Local $aTemp = _OL_FolderAccess($oOL, $vFolder) If @error Then Return SetError(1, @error, 0) $vFolder = $aTemp[1] EndIf Local $aResult[2] = [0, 0], $aTemp[2] ; Get size of all items in the specified folder For $oItem In $vFolder.Items $aResult[0] = $aResult[0] + $oItem.Size $aResult[1] = $aResult[1] + 1 Next ; Recursively calculate the size of all subfolders If $bRecursive Then For $oSubFolder In $vFolder.Folders $aTemp = _OL_FolderSize($oSubFolder, True) If not @error Then $aResult[0] = $aResult[0] + $aTemp[0] $aResult[1] = $aResult[1] + $aTemp[1] EndIf Next EndIf Return $aResult EndFunc ;==>_OL_FolderSize 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...
HighlanderSword Posted February 6, 2017 Share Posted February 6, 2017 works.... Thanks Link to comment Share on other sites More sharing options...
water Posted February 7, 2017 Author Share Posted February 7, 2017 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...
water Posted February 8, 2017 Author Share Posted February 8, 2017 (edited) I have updated function _OL_FolderSize and added new functions to _OL_StoreGet (Quotas and max. item size). _OL_FolderSize now uses a faster function to retrieve size values for Exchange folders. _OL_StoreGet now displays quota values for Exchange Stores: Warning Threshold represented in kilobytes (in KB) The limit at which a user can no longer send messages represented in kilobytes (KB) The limit where receiving mail is prohibited (also the maximum size of the mailbox) in kilobytes (KB) Contains the sum of the sizes of all properties in the mailbox or mailbox root in kilobytes (KB) The free space in the mailbox represented in kilobytes (KB) The maximum size for a message that a user can send represented in kilobytes (KB) What do you think? _OL_FolderSize example script Spoiler expandcollapse popup#include <OutlookEX.au3> #include <MsgBoxConstants.au3> #include <FileConstants.au3> ; ***************************************************************************** ; Connect to Outlook ; ***************************************************************************** Global $oOutlook = _OL_Open() If @error <> 0 Then Exit MsgBox($MB_ICONERROR, "OutlookEX UDF", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended) ; ***************************************************************************** ; Example 1 ; Calculate size of your Inbox (omitting subfolders) ; ***************************************************************************** Global $vResult = _OL_FolderSize($oOutlook, "*", Default, False, True) If @error <> 0 Then Exit MsgBox($MB_ICONERROR, "OutlookEX UDF: _OL_FolderSize Example Script 1", "Error calculating folder size. @error = " & @error & ", @extended = " & @extended) MsgBox($MB_ICONINFORMATION, "OutlookEX UDF: _OL_FolderSize Example Script 1", "Size of your inbox (excluding subfolders) is " & $vResult & " bytes.") ; ***************************************************************************** ; Example 2 ; Calculate size of your Inbox (including all subfolders) ; ***************************************************************************** $vResult = _OL_FolderSize($oOutlook, "*", Default, True, True) If @error <> 0 Then Exit MsgBox($MB_ICONERROR, "OutlookEX UDF: _OL_FolderSize Example Script 2", "Error calculating folder size. @error = " & @error & ", @extended = " & @extended) MsgBox($MB_ICONINFORMATION, "OutlookEX UDF: _OL_FolderSize Example Script 2", "Size of your inbox (including subfolders) is " & $vResult & " bytes.") ; ***************************************************************************** ; Example 3 ; Calculate size and number of items of your Inbox (including all subfolders) ; ***************************************************************************** MsgBox($MB_ICONINFORMATION, "OutlookEX UDF: _OL_FolderSize Example Script 4", "Processing your inbox might take a few minutes!", 5) $vResult = _OL_FolderSize($oOutlook, "*", Default, True, False) If @error <> 0 Then Exit MsgBox($MB_ICONERROR, "OutlookEX UDF: _OL_FolderSize Example Script 3", "Error calculating folder size. @error = " & @error & ", @extended = " & @extended) _ArrayDisplay($vResult, "OutlookEX UDF: _OL_FolderSize Example Script 3", "", 0, Default, "total size|number of items") ; ***************************************************************************** ; Example 4 ; Calculate size and number of items for a PST (including all subfolders) ; ***************************************************************************** Global $sPath = FileOpenDialog("Please select a PST file to process!", "C:\", "PST files (*.pst)", BitOR($FD_FILEMUSTEXIST, $FD_PATHMUSTEXIST)) If @error Then Exit Global $oPST = _OL_PSTAccess($oOutlook, $sPath) $vResult = _OL_FolderSize($oOutlook, $oPST, Default, True, False) If @error <> 0 Then Exit MsgBox($MB_ICONERROR, "OutlookEX UDF: _OL_FolderSize Example Script 4", "Error calculating folder size. @error = " & @error & ", @extended = " & @extended) _ArrayDisplay($vResult, "OutlookEX UDF: _OL_FolderSize Example Script 4") _OL_Close($oOutlook) _OL_FolderSize function Spoiler expandcollapse popup; #FUNCTION# ==================================================================================================================== ; Name...........: _OL_FolderSize ; Description ...: Returns information about the size and number of items of a folder and subfolders. ; Syntax.........: _OL_FolderSize($oOL[, $vFolder = "*"[, $iFolderType = Default[, $bRecursive = True[, $bSizeOnly = True]]]) ; Parameters ....: $oOL - Outlook object returned by a preceding call to _OL_Open() ; $vFolder - Optional: Folder object as returned by _OL_FolderAccess or full name of folder (default = "*" = The root folder of the current user) ; $iFolderType - Optional: Type of folder if you want to access a default folder. Is defined by the Outlook OlDefaultFolders enumeration (default = Default) ; $bRecursive - Optional: Calculates all subfolders of the specified folder as well (default = True) ; $bSizeOnly - Optional: Specifies that only the size of the folder and all subfolders will be returned (default = True) ; Return values .: Success - one-dimensional zero based array with the following information: ; |0 - Size of the specified folder/subfolders in Bytes ; |1 - Number of items in the specified folder/subfolders ; Failure - Returns "" and sets @error: ; |1 - Error accessing specified folder. See @extended for the error code of _OL_AccessFolder ; |2 - Error calling the PropertyAccessor for the specified folder. @extended is set to the COM error code ; |3 - Error accessing the PR_MESSAGE_SIZE_EXTENDED property. @extended is set to the COM error code ; Author ........: water ; Modified.......: ; Remarks .......: The returned size might differ from what Outlook reports. That's because Outlook folders hold some hidden items ; which are invisible for the UDF. ;+ ; For $bSizeOnly = False or for none Exchange folders the function is not very fast as it has to query all items for its size. ; Related .......: ; Link ..........: ; Example .......: Yes ; =============================================================================================================================== Func _OL_FolderSize($oOL, $vFolder, $iFolderType = Default, $bRecursive = True, $bSizeOnly = True) If Not IsObj($vFolder) Then If StringStripWS($vFolder, 3) = "" Then $vFolder = "*" Local $aFolder = _OL_FolderAccess($oOL, $vFolder, $iFolderType) If @error Then Return SetError(1, @error, 0) $vFolder = $aFolder[1] EndIf Local $aResult[2] = [0, 0], $aTemp[2] ; Property only works for Exchange Stores and only returns the size of the current folder without subfolders ; If $bSizeOnly = True And $bRecursive = False And ($vFolder.Store.ExchangeStoreType = $olExchangePublicFolder Or $vFolder.Store.ExchangeStoreType = $olPrimaryExchangeMailbox) Then If $bSizeOnly = True And ($vFolder.Store.ExchangeStoreType = $olExchangePublicFolder Or $vFolder.Store.ExchangeStoreType = $olPrimaryExchangeMailbox) Then Local $oPropertyAccessor = $vFolder.PropertyAccessor If @error Then Return SetError(2, @error, 0) Local $PR_MESSAGE_SIZE_EXTENDED = $oPropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x0E080014") ; Bytes If @error Then Return SetError(3, @error, 0) $aResult[0] = $PR_MESSAGE_SIZE_EXTENDED Else ; Get size of all items in the specified folder For $oItem In $vFolder.Items $aResult[0] = $aResult[0] + $oItem.Size $aResult[1] = $aResult[1] + 1 Next EndIf ; Recursively calculate the size of all subfolders If $bRecursive Then For $oSubFolder In $vFolder.Folders $vTemp = _OL_FolderSize($oOL, $oSubFolder, Default, True, $bSizeOnly) If $bSizeOnly Then $aResult[0] = $aResult[0] + $vTemp Else $aResult[0] = $aResult[0] + $vTemp[0] $aResult[1] = $aResult[1] + $vTemp[1] EndIf Next EndIf If $bSizeOnly Then Return $aResult[0] Return $aResult EndFunc ;==>_OL_FolderSize _OL_StoreGet function Spoiler expandcollapse popup; #FUNCTION# ==================================================================================================================== ; Name ..........: _OL_StoreGet ; Description ...: Returns information about the Stores in the current profile. ; Syntax.........: _OL_StoreGet($oOL) ; Parameters ....: $oOL - Outlook object returned by a preceding call to _OL_Open() ; Return values .: Success - two-dimensional one based array with the following information: ; |00 - display name of the Store object ; |01 - Constant in the OlExchangeStoreType enumeration that indicates the type of an Exchange store ; |02 - Full file path for a Personal Folders File (.pst) or an Offline Folder File (.ost) store ; |03 - True if the store is a cached Exchange store ; |04 - True if the store is a store for an Outlook data file (Personal Folders File (.pst) or Offline Folder File (.ost)) ; |05 - True if Instant Search is enabled and operational ; |06 - True if the Store is open ; |07 - String identifying the Store (StoreID) ; |08 - True if the OOF (Out Of Office) is set for this store ; |09 - Warning Threshold represented in kilobytes (in KB) ; |10 - The limit at which a user can no longer send messages represented in kilobytes (KB) ; |11 - The limit where receiving mail is prohibited (also the maximum size of the mailbox) in kilobytes (KB) ; |12 - Contains the sum of the sizes of all properties in the mailbox or mailbox root in kilobytes (KB) ; |13 - The free space in the mailbox represented in kilobytes (KB) ; |14 - The maximum size for a message that a user can send represented in kilobytes (KB) ; Failure - Returns "" and sets @error: ; |1 - Function is only supported for Outlook 2007 and later ; Author ........: water ; Modified ......: ; Remarks .......: This function only works for Outlook 2007 and later. ; It always returns a valid filepath for PST files where function _OL_PSTGet might not (hebrew characters in filename etc.) ; + ; A store object represents a file on the local computer or a network drive that stores e-mail messages and other items. ; If you use an Exchange server, you can have a store on the server, in an Exchange Public folder, or on a local computer ; in a Personal Folders File (.pst) or Offline Folder File (.ost). ; For a POP3, IMAP, and HTTP e-mail server, a store is a .pst file. ;+ ; The returned quota information can be represented as -1 (property not set for the store) or -2 (Quota data not available for local storage). ; Related .......: ; Link ..........: ; Example .......: Yes ; =============================================================================================================================== Func _OL_StoreGet($oOL) ; References: ; Accessing Exchange properties: https://msdn.microsoft.com/EN-US/library/office/ff863046.aspx ; Outlook quotas: http://blogs.technet.com/b/outlooking/archive/2013/09/19/mailbox-quota-in-outlook-2010-general-information-and-troubleshooting-tips.aspx ; Properties for quotas: http://blogs.msdn.com/b/stephen_griffin/archive/2012/04/17/cached-mode-quotas.aspx ; Property format: https://msdn.microsoft.com/en-us/library/ee159391(v=exchg.80).aspx ; http://schemas.microsoft.com/mapi/proptag/0xQQQQRRRR ; QQQQ = id ; RRRR = type Local $aVersion = StringSplit($oOL.Version, '.') If Int($aVersion[1]) < 12 Then Return SetError(1, 0, "") Local $iIndex = 0, $iStoreType, $oPropertyAccessor Local $aStore[$oOL.Session.Stores.Count + 1][15] = [[$oOL.Session.Stores.Count, 14]] For $oStore In $oOL.Session.Stores $iIndex = $iIndex + 1 $iStoreType = $oStore.ExchangeStoreType $aStore[$iIndex][0] = $oStore.DisplayName $aStore[$iIndex][1] = $iStoreType $aStore[$iIndex][2] = $oStore.FilePath $aStore[$iIndex][3] = $oStore.IsCachedExchange $aStore[$iIndex][4] = $oStore.IsDataFileStore $aStore[$iIndex][5] = $oStore.IsInstantSearchEnabled $aStore[$iIndex][6] = $oStore.IsOpen $aStore[$iIndex][7] = $oStore.StoreId $oPropertyAccessor = $oStore.PropertyAccessor If $iStoreType = $olExchangeMailbox Or $iStoreType = $olPrimaryExchangeMailbox Then $aStore[$iIndex][8] = $oPropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x661D000B") EndIf If $iStoreType = $olExchangePublicFolder Or $iStoreType = $olPrimaryExchangeMailbox Then ; Warning Threshold (in KB) $PR_QUOTA_WARNING = $oPropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x341A0003") $aStore[$iIndex][9] = (@error = 0) ? $PR_QUOTA_WARNING : -1 ; The limit where sending mail is prohibited (in KB) $PR_QUOTA_SEND = $oPropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x341B0003") $aStore[$iIndex][10] = (@error = 0) ? $PR_QUOTA_SEND : -1 ; The limit where receiving mail is prohibited (also the maximum size of the mailbox) (in KB) $PR_QUOTA_RECEIVE = $oPropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x341C0003") $aStore[$iIndex][11] = (@error = 0) ? $PR_QUOTA_RECEIVE : -1 ; Contains the sum of the sizes of all properties in the mailbox or mailbox root (in Bytes) $PR_MESSAGE_SIZE_EXTENDED = $oPropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x0E080014") ; Bytes If @error Then $aStore[$iIndex][12] = -1 $aStore[$iIndex][13] = -1 Else $aStore[$iIndex][12] = (@error = 0) ? (Round($PR_MESSAGE_SIZE_EXTENDED / 1024)) : -1 $aStore[$iIndex][13] = Round($aStore[$iIndex][11] - $aStore[$iIndex][12]) EndIf ; The maximum size for a message that a user can send (in KB) $PR_MAX_SUBMIT_MESSAGE_SIZE = $oPropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x666d0003") $aStore[$iIndex][14] = (@error = 0) ? $PR_MAX_SUBMIT_MESSAGE_SIZE : -1 Else ; Quota data not available for local storage $aStore[$iIndex][9] = -2 $aStore[$iIndex][10] = -2 $aStore[$iIndex][11] = -2 $aStore[$iIndex][12] = -2 $aStore[$iIndex][13] = -2 $aStore[$iIndex][14] = -2 EndIf Next Return $aStore EndFunc ;==>_OL_StoreGet Edited February 8, 2017 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...
HighlanderSword Posted February 10, 2017 Share Posted February 10, 2017 Hello Water, Can you please check function _OL_AccountGet, When a user removes email accounts from the Profile ( In Outlook, click on file, account settings, them remove email account), the function does not seem to see these updates for example I deleted 3 pop3 email accounts and then ran the function and i still listed the 3 accounts I removed. I went back to account settings in outlook and the accounts were not there. I closed outlook down and the re-started outlook and re-tried the function and it worked correctly, is it possible the accounts are stored in cache somewhere ? Link to comment Share on other sites More sharing options...
water Posted February 10, 2017 Author Share Posted February 10, 2017 The UDF functions just query the Outlook COM object model. Maybe dropping an account just closes the Store. You could test by using property IsOpen.https://msdn.microsoft.com/en-us/library/ff860623(v=office.14).aspx 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