HighlanderSword Posted June 2, 2020 Share Posted June 2, 2020 Hello, I'm using version 1.5, Once I have completed a search for email that match my criteria , I return those results to an array, Next i need to move them all to the same folder, currently do a loop to go thru each email one at a time to move them to the folder. Is there a Better way to do this as the number of Items returned can be over 5k Below is a snippet of the code I'm using local $emailList = _OL_ItemSearch($oOutlook, $rules[$Process_Rules][2], $sfilter, "EntryID,Subject,From,Categories,SenderEmailAddress,ReceivedTime") For $email_Loop = 1 To UBound($emailList) - 1 _ol_itemmove($oOutlook, $emailList[$email_Loop][0], Default, $Strmovetofolder) next Link to comment Share on other sites More sharing options...
water Posted June 2, 2020 Share Posted June 2, 2020 Is $Strmovetofolder the folder object as returned by _OL_FolderAccess or a string describing the folder? 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 June 3, 2020 Author Share Posted June 3, 2020 (edited) it is a string that contains the pst name and the folder with in it , an example is History\Autoit_Email ( History is the pst name aka History.pst ) Edited June 3, 2020 by HighlanderSword Link to comment Share on other sites More sharing options...
water Posted June 3, 2020 Share Posted June 3, 2020 Use _OL_PSTAccess and _OL_FolderAccess and pass the folder object to _OL_ItemMove. So this step hasn't to be done for every item. If it is still too slow you could strip down the _OL_ItemMove function and create your own. 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...
MrCreatoR Posted June 3, 2020 Share Posted June 3, 2020 11 hours ago, HighlanderSword said: I'm using version 1.5, Of what? I personally know what, but it's not a standard UDF, so it's not obvious for all. Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
HighlanderSword Posted June 3, 2020 Author Share Posted June 3, 2020 This is in regards to Water's UDF OutlookEX.au3 Link to comment Share on other sites More sharing options...
HighlanderSword Posted June 3, 2020 Author Share Posted June 3, 2020 OK , what am I doing wrong , the _ol_pstaccess works with no issue , but _ol_folder_access is returing error code = 4 extended =1 #include <OutlookEX.au3> #include <Array.au3> Global $oOutlook = _OL_Open() Global $oPST = _OL_PSTAccess($oOutlook, "D:\History.pst", "") If @error <> 0 Then Exit MsgBox(16, "error", "error = " & @error & ", @extended: " & @extended) MsgBox(64, "worked ", "pst found") Global $aFolder = _OL_FolderAccess($oPST, "Autoit_Emails",Default) If @error <> 0 Then Exit MsgBox(16, "error","error = " & @error & " - extended = " & @extended) Global $aFolderDisplay[6][2] = [[$aFolder[0]],["","Folder object"],["","Default item type for the folder"],["", "StoreID where the folder resides"],["", "EntryID of the folder"],["", "Folder path"]] $aFolderDisplay[1][0] = $aFolder[1] $aFolderDisplay[2][0] = $aFolder[2] $aFolderDisplay[3][0] = $aFolder[3] $aFolderDisplay[4][0] = $aFolder[4] $aFolderDisplay[5][0] = $aFolder[5] _ArrayDisplay($aFolderDisplay, "display results") Link to comment Share on other sites More sharing options...
water Posted June 5, 2020 Share Posted June 5, 2020 (edited) _OL_Folderaccess needs the Outlook object as first parameter. Example: https://www.autoitscript.com/forum/topic/184286-read-email-with-outlook-udf/?do=findComment&comment=1324083 Edited June 5, 2020 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...
water Posted June 6, 2020 Share Posted June 6, 2020 As Outlook COM does not provide a way to bulk move items you could select all found items and then manually move them to the target folder. Should be much faster. I have created a function (beta) in OutlookEX_GUI to select/unselect all or selected items. I can post here if needed. 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 June 7, 2020 Author Share Posted June 7, 2020 Please do post the Beta Link to comment Share on other sites More sharing options...
water Posted June 7, 2020 Share Posted June 7, 2020 Function: Spoiler expandcollapse popup; #FUNCTION# ==================================================================================================================== ; Name ..........: _OL_SelectionSet ; Description ...: Add, remove all or a single item to the selection of the active or a selected Explorer. ; Syntax.........: _OL_SelectionSet($oOL, $vItem[, $iAction = 1[, $oExplorer = Default]]) ; Parameters ....: $oOL - Outlook object returned by a preceding call to _OL_Open() ; $vItem - Item to be processed. Can be: ; | object - Add or remove the item to/from the selection as specified in parameter $iAction ; | -1 - Add or remove all items to/from the selection as specified in parameter $iAction ; $iAction - [optional] Specifies how to process $vItem. 1 - adds the item(s), 2 - removes the item(s) ; $oExplorer - [optional] Explorer to process (default = active Explorer) ; Return values .: Success - 1 ; Failure - Returns 0 and sets @error: ; |1 - $vItem is invalid. Has to be an object, 0 or 1 ; |2 - Error adding the item to the selection. @extended is set to the COM error code ; |3 - Error adding all items of the view to the selection. @extended is set to the COM error code ; |4 - Error removing the item from the selection. @extended is set to the COM error code ; |5 - Error clearing the selection. @extended is set to the COM error code ; Author ........: water ; Modified ......: ; Remarks .......: A selected item does not get unselected if you select it again ; Related .......: ; Link ..........: ; Example .......: Yes ; =============================================================================================================================== Func _OL_SelectionSet($oOL, $vItem, $iAction = 1, $oExplorer = Default) If $iAction = Default Then $iAction = 1 If $oExplorer = Default Then $oExplorer = $oOL.ActiveExplorer() Switch $iAction Case 1 ; Add Select Case IsObj($vItem) ; Add a single Item $oExplorer.AddToSelection($vItem) If @error Then Return SetError(2, @error, 0) Case $vItem = -1 ; Add all items of the view $oExplorer.SelectAllItems() If @error Then Return SetError(3, @error, 0) Case Else Return SetError(1, @error, 0) EndSelect Case 2 ; Remove Select Case IsObj($vItem) ; Remove a single item $oExplorer.RemoveFromSelection($vItem) If @error Then Return SetError(4, @error, 0) Case $vItem = -1 ; Clear the selection $oExplorer.ClearSelection() If @error Then Return SetError(5, @error, 0) Case Else Return SetError(1, @error, 0) EndSelect EndSwitch Return 1 EndFunc ;==>_OL_SelectionSet Example: Spoiler expandcollapse popup#include <OutlookEX_GUI.au3> #include <MsgBoxConstants.au3> Global $oOL = _OL_Open() If @error <> 0 Then Exit MsgBox($MB_ICONERROR, "_OL_SelectionSet Example Script", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended) ; ***************************************************************************** ; Example 1 ; Select items 1 and 2 of the active view ; ***************************************************************************** _OL_SelectionSet($oOL, $oOL.ActiveExplorer.CurrentFolder.Items(1)) If @error <> 0 Then Exit MsgBox($MB_ICONERROR, "_OL_SelectionSet Example Script", "Error setting a selection. @error = " & @error & ", @extended = " & @extended) MsgBox($MB_ICONINFORMATION, "_OL_SelectionSet", "Item 1 selected!") _OL_SelectionSet($oOL, $oOL.ActiveExplorer.CurrentFolder.Items(2)) If @error <> 0 Then Exit MsgBox($MB_ICONERROR, "_OL_SelectionSet Example Script", "Error setting a selection. @error = " & @error & ", @extended = " & @extended) MsgBox($MB_ICONINFORMATION, "_OL_SelectionSet", "Item 2 selected!") ; *************************************************************************************** ; Example 2 ; Remove selection of item 2 ; *************************************************************************************** _OL_SelectionSet($oOL, $oOL.ActiveExplorer.CurrentFolder.Items(2), 2) If @error <> 0 Then Exit MsgBox($MB_ICONERROR, "_OL_SelectionSet Example Script", "Error unselecting an item. @error = " & @error & ", @extended = " & @extended) MsgBox($MB_ICONINFORMATION, "_OL_SelectionSet", "Item 2 unselected!") ; *************************************************************************************** ; Example 3 ; Select all items ; *************************************************************************************** _OL_SelectionSet($oOL, -1) If @error <> 0 Then Exit MsgBox($MB_ICONERROR, "_OL_SelectionSet Example Script", "Error selecting all items. @error = " & @error & ", @extended = " & @extended) MsgBox($MB_ICONINFORMATION, "_OL_SelectionSet", "All items Selectselected!") ; *************************************************************************************** ; Example 4 ; Remove all selected items ; *************************************************************************************** _OL_SelectionSet($oOL, -1, 2) If @error <> 0 Then Exit MsgBox($MB_ICONERROR, "_OL_SelectionSet Example Script", "Error unselecting all items. @error = " & @error & ", @extended = " & @extended) MsgBox($MB_ICONINFORMATION, "_OL_SelectionSet", "All items unselected!") _OL_Close($oOL) 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