How to Auto Move Different Types of Deleted Items into Different Folders via Outlook VBA

All kinds of Outlook items that you delete will be moved to “Deleted Items” folder. If you wish to move the deleted items to different folders depending on item type, you can read this post. Here we will teach you to get it step by step.

You must notice that all the deleted items will be moved to “Deleted Items” folder regardless of item type. Thereby, the “Deleted Items” folder is always stuffed with all kinds of items, such as deleted contacts, appointments, and notes, etc. In face of this scenario, if you want to store the items in different folders under “Deleted Items” folder on basis of different item types, you can use the following way to get it.

Auto Move Different Types of Deleted Items into Different Folders

  1. At first, go to Outlook VBA editor with reference to “How to Run VBA Code in Your Outlook“.
  2. Then, copy and paste the following VBA code into a module or project.
Public WithEvents objDeletedFolder As Outlook.folder
Public WithEvents objDeletedItems As Outlook.Items

Private Sub Application_Startup()
    Set objDeletedFolder = Outlook.Application.Session.GetDefaultFolder(olFolderDeletedItems)
    Set objDeletedItems = objDeletedFolder.Items
End Sub

Private Sub objDeletedItems_ItemAdd(ByVal Item As Object)
    Dim objTargetFolder As Outlook.folder
  
    Select Case TypeName(Item)
           Case "MailItem", "PostItem", "ReportItem", "MeetingItem"
                On Error Resume Next
                Set objTargetFolder = objDeletedFolder.Folders("Deleted Mails")
                If objTargetFolder Is Nothing Then
                   Set objTargetFolder = objDeletedFolder.Folders.Add("Deleted Mails", olFolderInbox)
                End If
           Case "ContactItem", "DistListItem"
                On Error Resume Next
                Set objTargetFolder = objDeletedFolder.Folders("Deleted Contacts")
                If objTargetFolder Is Nothing Then
                   Set objTargetFolder = objDeletedFolder.Folders.Add("Deleted Contacts", olFolderContacts)
                End If
           Case "AppointmentItem"
                On Error Resume Next
                Set objTargetFolder = objDeletedFolder.Folders("Deleted Appointments")
                If objTargetFolder Is Nothing Then
                   Set objTargetFolder = objDeletedFolder.Folders.Add("Deleted Appointments", olFolderCalendar)
                End If
           Case "TaskItem"
                On Error Resume Next
                Set objTargetFolder = objDeletedFolder.Folders("Deleted Tasks")
                If objTargetFolder Is Nothing Then
                   Set objTargetFolder = objDeletedFolder.Folders.Add("Deleted Tasks", olFolderTasks)
                End If
           Case "JournalItem"
                On Error Resume Next
                Set objTargetFolder = objDeletedFolder.Folders("Deleted Journals")
                If objTargetFolder Is Nothing Then
                   Set objTargetFolder = objDeletedFolder.Folders.Add("Deleted Journals", olFolderJournal)
                End If
           Case "NoteItem"
                On Error Resume Next
                Set objTargetFolder = objDeletedFolder.Folders("Deleted Notess")
                If objTargetFolder Is Nothing Then
                   Set objTargetFolder = objDeletedFolder.Folders.Add("Deleted Notess", olFolderNotes)
                End If
    End Select
 
    If Not objTargetFolder Is Nothing Then
       Item.Move objTargetFolder
    End If
End Sub

VBA Code - Auto Move Different Types of Deleted Items into Different Folders

  1. After that, restart your Outlook to activate this macro.
  2. From now on, every time when you delete an item, Outlook will auto move it to the corresponding type of folder under “Deleted Items” folder, as shown in the image below.Folders for Different Kinds of Deleted Items

Don’t Fear Outlook Data Corruption

Users tend to get panic in the event of Outlook crash in that Outlook file may be compromised. But, if you’ve made enough precautions, such worry is totally redundant. For example, if you have an updated PST backup, you can easily recover PST data from backups. Or if you have kept an experienced PST fix tool, such as DataNumen Outlook Repair, you can just use it to repair damaged PST file. In a nutshell, you should keep alert all the time.

Author Introduction:

Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including sql fix and outlook repair software products. For more information visit www.datanumen.com

Comments are closed.