Jump to content

_Ol_ItemMove question


Recommended Posts

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

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 - 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 (NEW 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

 

Link to comment
Share on other sites

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 - 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 (NEW 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

 

Link to comment
Share on other sites

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_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: 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 Program

AutoIt_Icon_small.pngUDFs: 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
 
AutoIt_Icon_small.pngExamples: 
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 AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

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

_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 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 - 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 (NEW 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

 

Link to comment
Share on other sites

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 - 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 (NEW 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

 

Link to comment
Share on other sites

Function:

Spoiler


; #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
#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 - 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 (NEW 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

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...