-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMoveItems.bas
33 lines (32 loc) · 1.2 KB
/
MoveItems.bas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Attribute VB_Name = "MoveItems"
Option Explicit
Sub MoveItems()
MoveItemsImpl ThisOutlookSession.GetFolder("[email protected] (old)"), ThisOutlookSession.GetFolder("[email protected]")
End Sub
Function MoveItemsImpl(ByVal source As Outlook.Folder, ByVal destination As Outlook.Folder, Optional subfolderName As String = "")
Dim miv() As Variant, fld As Outlook.Folder
Dim mi As Variant
Dim i As Integer
trace.trace "MoveItemsImpl " & source.folderPath
DoEvents
If Not subfolderName = "" Then
Set destination = Utilities.EnsureFolderExists(destination, subfolderName)
End If
If source.Items.Count > 0 Then
ReDim miv(1 To source.Items.Count)
For Each mi In source.Items
i = i + 1
Set miv(i) = mi
Next mi
For i = 1 To UBound(miv)
Utilities.moveItem miv(i), destination, source.name
DoEvents
Next i
End If
trace.trace "Moved " & i & " items out of " & source.folderPath
For Each fld In source.folders
i = i + MoveItemsImpl(fld, destination, fld.name)
Next fld
trace.trace "Moved " & i & " items below " & source.folderPath
MoveItemsImpl = i
End Function