VBOffice

Empty a Folder

Delete the content of a folder with a single click.

Last modified: 2007/04/05 | Accessed: 28.021  | #51
◀ Previous sample Next sample ▶
SAM SAM
Determine the "identity" of your emails. Set with SAM the sender, signature and folder for sent items with the help of rules.

For instance, if you want to empty a junk folder, there is a command for that in the context menu. However, for most folders that command is not available.

This script deletes the content of the current folder. Create a new command on the toolbar (Outlook 2007 or older), or on the QAT since Outlook 2010 to get the Empty Folder command for any folder.

Here's another code for IMAP folder: Purge Deleted IMAP messages


tip  How to add macros to Outlook
Public Sub DeleteFolderContent()
  Dim Folder As Outlook.MAPIFolder
  Dim Items As Outlook.Items
  Dim Msg As String
  Dim i As Long

  Set Folder = Application.ActiveExplorer.CurrentFolder
  Set Items = Folder.Items

  Msg = Items.Count & " items in " & Folder.Name & ". Delete?"

  If MsgBox(Msg, vbYesNo) = vbYes Then
    For i = Items.Count To 1 Step -1
      Items.Remove i
    Next
  End If
End Sub
Reporter Reporter
VBOffice Reporter is an easy to use tool for data analysis and reporting in Outlook. A single click, for instance, allows you to see the number of hours planned for meetings the next month.
email  Send a message