outlook-vba Introduction Part 3: Stores and all their folders 3.5 Moving a folder from one parent folder to another


Example

Why do I want to reference a folder? In the next part I will show you how to access emails within a referenced folder. Here I will show you how to move a folder. I created a folder named “Test” within my Inbox. In TestMoveFolder(), I replaced “A” with the name of the store containing my Inbox. Running TestMoveFolder() moved “Test” to “Deleted Items”.

Sub TestMoveFolder()

  Dim FldrDest As Folder
  Dim FldrToMove As Folder

  Set FldrToMove = Session.Folders("A").Folders("Inbox").Folders("Test")
  Set FldrDest = Session.Folders("A").Folders("Deleted Items")
  
  FldrToMove.MoveTo FldrDest

End Sub