Last active
February 6, 2018 15:47
-
-
Save AndyDaSilva52/0648a4804f644fa08dd5ea65c1ff861d to your computer and use it in GitHub Desktop.
Create Folders and Subfolders in Outlook Folder Structure - Choose a Origim Folder and Create the same Subfolders in the Destination
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub CreateFolders() | |
Dim olNS As NameSpace | |
Dim olFolder As Folder | |
Dim OlNewFolder As Folder | |
Dim olNewFolders As Folders | |
Dim olItems As Items | |
Dim olItem As MailItem | |
Dim strName As String | |
Dim i As Long | |
Set olNS = Application.GetNamespace("MAPI") | |
Set olFolder = olNS.PickFolder | |
Set OlNewFolder = olNS.PickFolder | |
Set olNewFolders = OlNewFolder.Folders | |
Set olItems = olFolder.Items | |
On Error Resume Next | |
For i = olItems.Count To 1 Step -1 | |
Set olItem = olItems(i) | |
strName = olItem.Sender | |
olNewFolders.Add strName, olFolderInbox | |
olItem.Move olNewFolders(strName) | |
Next i | |
lbl_Exit: | |
Exit Sub | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment