How to Batch Remove Attachments from Outdated Calendar Items in Your Outlook

If you wish to remove attachments from outdated appointments and meetings in your Outlook, you can read this article. Here we will introduce you how to realize it in one go.

To reduce the size of your Outlook file, it is highly advisable to clean up old items. This can be realized by the inbuilt “AutoArchive” feature, which can delete the old items automatically at regular intervals. However, some users just wish to delete the attachments in the old items without impacting the items themselves. In the followings, we’ll teach you to bulk remove attachments from old calendar items.

Batch Remove Attachments from Old Calendar Items in Your Outlook

Batch Remove Attachments from Outdated Calendar Items

  1. To begin with, access Outlook VBA editor by “Alt + F11”.
  2. Then, in the “Microsoft Visual Basic for Applications” window, copy the VBA code into a module.
Sub BatchDeleteAttachmentsOfOldCalendarItems()
    Dim objOutlookFile As Outlook.Folder
    Dim objFolder As Outlook.Folder
 
    'Change to your own Outlook file
    Set objOutlookFile = Outlook.Application.Session.Folders("John Smith")
 
    For Each objFolder In objOutlookFile.Folders
        If objFolder.DefaultItemType = olAppointmentItem Then
           Call LoopCalendars(objFolder)
        End If
    Next
End Sub

Sub LoopCalendars(ByVal objCalendar As Outlook.Folder)
    Dim i, n As Long
    Dim objCalendarItem As Outlook.AppointmentItem
    Dim nDateDiff As Integer
    Dim objAttachments As Outlook.Attachments
    Dim objSubCalendar As Outlook.Folder
 
    For i = objCalendar.Items.Count To 1 Step -1
        Set objCalendarItem = objCalendar.Items(i)
 
        'Remove attachments from items that are more than 2 months old
        'Change the datediff as per your needs
        nDateDiff = DateDiff("m", objCalendarItem.End, Now) '=> "m" refers to month; "d" for day; "y" for year
        If nDateDiff > 2 Then
           Set objAttachments = objCalendarItem.Attachments
           If objAttachments.Count > 0 Then
              For n = objAttachments.Count To 1 Step -1
                  objAttachments(n).Delete
              Next
           End If
           objCalendarItem.Save
        End If
    Next

    'Process all subfolders recursively
    If objCalendar.Folders.Count > 0 Then
       For Each objSubCalendar In objCalendar.Folders
           Call LoopCalendars(objSubCalendar)
       Next
    End If
End Sub

VBA Code - Batch Remove Attachments from Outdated Calendar Items

  1. Afterwards, click in “BatchDeleteAttachmentsOfOldCalendarItems” macro.
  2. Ultimately, press “F5” key button to run this macro.
  3. When macro completes, you can check all of your Outlook calendars.
  4. Outlook must have deleted all the attachments of the calendar items that are more than 2 months old.Removed Attachments from Outdated Calendar Items

Cope with Corrupt Outlook Files

Have you ever encountered Outlook corruption? How do you dispose of it usually? More often than not, you would firstly try the inbox repair tool – Scanpst. But, in case of serious PST damage, the built-in utility can’t help you. Thus, it’s suggested to keep a more experienced and remarkable third party tool in vicinity, such as DataNumen Outlook Repair.

Author Introduction:

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

Leave a Reply

Your email address will not be published. Required fields are marked *