Afternoon All,
I have the following structure in my Outlook:
Mapi > peter*********com > !!!INCIDENTS > !APS PV >!Archive
I would like to place ALL subfolders in subfolder !APS PV
into subfolder !Archive
.
My code looks to loop through the subfolder and moves each. I have no issues moving the subfolders, it's loading all the subfolders into an array. No items are being returned.
Dim olFolder As Outlook.MAPIFolder
Dim SubFolder As Outlook.MAPIFolder
Dim olNs As Outlook.NameSpace
Dim Item As Object
Dim lngCount As Long
Dim Items As Outlook.Items
On Error GoTo MsgErr
' Set Inbox Reference
Set olNs = Application.GetNamespace("MAPI")
Set olFolder = olNs.GetDefaultFolder(olFolderInbox).Parent
Set Items = olFolder.Items
Set olFolder = olFolder.Folders("!!!INCIDENTS")
Set Items = olFolder.Items
Set olFolder = olFolder.Folders("!APS PV")
Set Items = olFolder.Items
' // Loop through the Items in the folder backwards
For lngCount = Items.Count To 1 Step -1
Set Item = Items(lngCount)
Debug.Print Item.Subject
If Item.Class = olMail Then
' // Set SubFolder of Inbox
Set SubFolder = olFolder.Folders("!Archive")
' // Mark As Read
Item.UnRead = False
' // Move Mail Item to sub Folder
Item.Move SubFolder
End If
Next lngCount
The Items.Count
returns zero despite many subfolders existing.
Peter