问题
I am trying to put code into Outlook VBA where I can loop through all my offline folders and run the "Clean Up Folder & Subfolders" menu command on each folder. I have tried several items and cannot get anything to work. There is very little online and no working code. All suggestions point to Application.CommandBars.ExecuteMso ("ThreadCompressFolderRecursive"), but that object does not exist. Any Ideas?
回答1:
Not the Application. Use Inspector or Explorer as required.
Sub ExecuteMso_CleanUP()
Dim objExpl As Explorer
Set objExpl = ActiveExplorer
objExpl.CommandBars.ExecuteMso ("ThreadCompressFolderRecursive")
End Sub
来源:https://stackoverflow.com/questions/44553378/outlook-2016-vba-run-clean-up-folder-via-code