Created
December 8, 2022 20:23
-
-
Save craibuc/8838378e8be3d3cb5fa6323b30a1bcbe to your computer and use it in GitHub Desktop.
Empty deleted items and junk folders
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
| ' | |
| ' macro's entry point | |
| ' | |
| Public Sub EmptyJunkTrash() | |
| EmptyFolder (olFolderJunk) | |
| EmptyFolder (olFolderDeletedItems) | |
| End Sub | |
| ' | |
| ' delete items and subfolders from the specified folder | |
| ' | |
| Sub EmptyFolder(Folder As OlDefaultFolders) | |
| Dim oFolder As Outlook.Folder: Set oFolder = Application.Session.GetDefaultFolder(Folder) | |
| Dim oItems As Outlook.Items: Set oItems = oFolder.Items | |
| Dim i As Long | |
| For i = oItems.Count To 1 Step -1 | |
| oItems.Item(i).Delete | |
| Next | |
| Dim oSubFolders As Outlook.Folders: Set oSubFolders = oFolder.Folders | |
| For i = oSubFolders.Count To 1 Step -1 | |
| oSubFolders.Item(i).Delete | |
| Next | |
| End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment