How to Batch Apply Same “AutoArchive” Setting to All Outlook Folders

Sometimes, you may want to apply a same “AutoArchive” setting to all folders. But, by default, Outlook only allows you to change “AutoArchive” settings for folders one by one, which is very tedious. So, here we will share you a far more effective way, which can accomplish this task in bulk.

After reading the previous article – “How to Batch Disable “AutoArchive” Option for All Outlook Folders“, many users ask for a similar approach, which can permit them to batch apply the same “AutoArchive” settings to all Outlook folder. Such a way can help them free of changing the settings one by one. Hence, thereinafter, we will introduce such an approach in detail.Batch Apply Same "AutoArchive" Setting to All Outlook Folders

Batch Apply Same “AutoArchive” Setting to All Folders

  1. Firstly, in Outlook, open VBA editor by “Alt + F11”.
  2. Then, in the new window, put the VBA code below into a blank module or project.
Sub BatchChangeAutoArchiveSettingsForAllFolders()
    Dim objStore As Outlook.Store
    Dim objFolder As Outlook.Folder
 
    'Specify a Outlook file
    'Replace "John Smith" with the displaying name of your own file
    Set objStore = Application.Session.Stores.Item("John Smith")
 
    For Each objFolder In objStore.GetRootFolder.Folders
        Call ProcessFolders(objFolder)
    Next
 
    MsgBox "Completed!", vbInformation + vbOKOsnly
End Sub

Sub ProcessFolders(objFolder As Outlook.Folder)
    Dim objStorageItem As Outlook.StorageItem
    Dim strArchiveFile As String
    Dim objSubfolder As Outlook.Folder

    Const PR_AGING_AGE_FOLDER = "http://schemas.microsoft.com/mapi/proptag/0x6857000B"
    Const PR_AGING_DEFAULT = "http://schemas.microsoft.com/mapi/proptag/0x685E0003"
    Const PR_AGING_GRANULARITY = "http://schemas.microsoft.com/mapi/proptag/0x36EE0003"
    Const PR_AGING_PERIOD = "http://schemas.microsoft.com/mapi/proptag/0x36EC0003"
    Const PR_AGING_DELETE_ITEMS = "http://schemas.microsoft.com/mapi/proptag/0x6855000B"
    Const PR_AGING_FILE_NAME_AFTER9 = "http://schemas.microsoft.com/mapi/proptag/0x6859001E"

    Set objStorageItem = objFolder.GetStorage("IPC.MS.Outlook.AgingProperties", olIdentifyByMessageClass)
 
    'Specify the archive PST file
    strArchiveFile = "C:\Users\Test\My Documents\Outlook Files\Archive.pst"
 
    With objStorageItem.PropertyAccessor
         'AutoArchive items older than 3 weeks
         'Change the following values as per your real needs
         .SetProperty PR_AGING_AGE_FOLDER, True
         .SetProperty PR_AGING_DEFAULT, 0 '==> not use default settings
                                          '==> use 1 for default file location
                                          '==> use 2 for default all settings
         .SetProperty PR_AGING_GRANULARITY, 1 '==> unit: weeks
                                              '==> use 0 for months
                                              '==> use 2 for days
         .SetProperty PR_AGING_PERIOD, 3 ' ==> must 1 to 999
         .SetProperty PR_AGING_DELETE_ITEMS, False '==> not permanently delete old items
         .SetProperty PR_AGING_FILE_NAME_AFTER9, strArchiveFile
    End With

    objStorageItem.Save
 
    'Process all subfolders recursively
    If objFolder.Folders.Count > 0 Then
       For Each objSubfolder In objFolder.Folders
           Call ProcessFolders(objSubfolder)
       Next
    End If
End Sub

VBA Code - Batch Apply Same "AutoArchive" Setting to All Folders

Note: According to the comments in the VBA code, you have to change the exact values as per your own situations.

  1. Subsequently, you can run the macro by “F5” key button.
  2. When macro finishes, you can check “AutoArchive” settings of all folders. They must have been changed, like the screenshot.Same "AutoArchive" Setting to All Folders

Safeguard Your Outlook Data

There are a variety of risks around your Outlook PST file, such as viruses, etc. In this case, you have to make diverse actions to protect your Outlook data, say making regular data backups, keeping cautious of viruses or malware as well as preparing a powerful repair tool in vicinity, like DataNumen Outlook Repair. It can come to your rescue when the inbox repair tool cannot help you to repair the corrupt Outlook file.

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.