Last active
February 28, 2019 14:45
-
-
Save hvmonteiro/6c0e05042a91f28c246fa2cebda6a3d3 to your computer and use it in GitHub Desktop.
Outlook macro to read selected items, clean up folder and archive items.
This file contains 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
'Outlook VB Macro to Unread, CleanUp Folder & subFolders | |
' and Archive Selected items | |
Private Sub CleanUpAllFolders() | |
Dim objExpl As Explorer | |
Set objExpl = ActiveExplorer | |
objExpl.CommandBars.ExecuteMso ("ThreadCompressFolderRecursive") | |
End Sub | |
' Archive current selected conversation (when no individual items are selected) | |
' It works on collapsed and expanded conversations of emails | |
' | |
Private Sub ArchiveConversation() | |
On Error Resume Next | |
Set ArchiveFolder = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Parent.Folders("Archive") | |
Set Conversations = ActiveExplorer.Selection.GetSelection(Outlook.OlSelectionContents.olConversationHeaders) | |
For Each Header In Conversations | |
Set Items = Header.GetItems() | |
For i = 1 To Items.Count | |
Items(i).UnRead = False | |
Items(i).Move ArchiveFolder | |
Next i | |
Next Header | |
End Sub | |
Sub execute() | |
result = MsgBox("Mark Items as Read and Archive?", vbYesNo) | |
If result = vbYes Then | |
Debug.Print ("Marking selected items as read, cleaning up folders anr archive emails.") | |
CleanUpAllFolders | |
ArchiveConversation | |
Else | |
MsgBox ("Canceled!") | |
End If | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Outlook 2010
Description
This macro is specially useful when you have a lot of emails that are not directly meant for you to reply/follow, but rather for your team, and you want to Mark the Email or conversation thread as Read, Clean Up Folder & SubFolders (which will remove the unnecessary emails that have the same information) and Archive the email.
Usage
To use this macro you need to enable Development ribbon/toolbar and create a new Macro:
Activate Developer Toolbar
The Developer toolbar will now be available in ribbon bar, among the Home, Send / Receive, Folder, View and Help.
Create the Macro
The new macro will now be available in the drop down Macros menu. If you select and email or conversation, and press the newly creatd macro on that menu, it will popup a message box asking if you want to clear the selected items.
Note: You can now also had the macro to a toolbar so that you can more quickly use it any time. Check Outlook Help on how to add custom buttons the the toolbars.