Outlook – Bulk compaction of 700GB of PST files

microsoft-outlookpst

I am working on a archive migration, in which I am extracting mail from 700GB of PST files, and sending it to an email archive. Once a message was extracted, it is deleted from the PST file using a custom utility.

However this leaves me with 700GB of mostly empty PST files.

For compliance reasons, I need to retain the messages that could not be extracted, and I need to reclaim disk space too.

Is there a way to bulk compact the PST files? I can't find much useful software online to do this.

If I take a 500MB PST file and zip it, I am left with a 230MB archive.
However if I use Outlook 2007 to compact it, I am left with a 15MB PST.

Anyone have any ideas on how to bulk compact thousands of PST files? I'm not looking for a solution like CompressPST which removes attachments and whatnot, as the files are 99% empty.

I couldn't find any command line switches for outlook to accomplish this.

Best Answer

  • OK, I accomplished this using SmartPST (Freeware) and AutoIT (Freeware.)

    With SmartPST I can bulk add PST files into my Outlook profile. Drag and drop.

    And the following AutoIT script I dug up iterates through each and compacts. Run it in a VM to not get your current work avoided.

    This ended up being the best I could ask for. A drag and drop, then click solution. :) IT Automation doesn't get better than that.

    #include <GUIListView.au3>
    SplashTextOn("Compacting now", "This may take hours...", 250, 40)
    ;//Runs the mail application that is in control panel.
    $Path = FileGetShortName(RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Control Panel\Cpls", "mlcfg32.cpl"))
    Run(@SystemDir & "\control.exe " & $Path)
    Opt("WinTitleMatchMode", 4)
    WinWait("Mail Setup - Outlook", "Setup e-mail accounts and dire")
    ControlClick("Mail Setup - Outlook", "Setup e-mail accounts and dire", "Button2")
    WinWait("Account Settings", "AcctMgr Tab")
    ;//Gets list of data files listed
    $sTitle = "Account Settings"
    $hWnd = WinGetHandle($sTitle)
    If @error Then
     MsgBox(0, "Error", "Unable to find window")
    EndIf
    WinActivate($hWnd)
    $hlist = ControlGetHandle($hWnd, "", "[CLASS:SysListView32; INSTANCE:2]")
    If @error Then Exit
    $arraycount = _GUICtrlListView_GetItemCount($hlist)
    Local $ltext[$arraycount]
    $i = 0
    Do
     $ltext[$i] = _GUICtrlListView_GetItemText($hlist, $i)
     $i = $i + 1
    Until $i = $arraycount
    ;//Goes into each listed Data file and compresses them
    $b = 0
    Do
     _GUICtrlListView_ClickItem($hlist, $b, "left", False, 2)
     Sleep(1000)
     WinWaitActive("Outlook Data File")
     ControlClick("Outlook Data File", "", "[CLASS:Button; INSTANCE:2]") ; click Compact Now
     Sleep(1200)
     If WinExists("Compact Now") Then WinWaitClose("Compact Now")
     WinClose("Outlook Data File")
     $b = $b + 1
    Until $b = $arraycount
    WinClose("Outlook Data Files")
    WinClose("Account Settings")
    WinClose("Mail Setup - Outlook")
    SplashOff()
    MsgBox(64, "Outlook", "All accounts were processed." & @CRLF & "Closing in 5 seconds...", 5)
    Exit