Compartilhar via


Scripting: Remove all PST files in an outlook profile

Building on, this code will remove the mapping that has been done in outlook for ALL PST files.

 'On Error resume next
 Dim objOutlook 'As Outlook.Application
 Dim Session 'As Outlook.NameSpace
 Dim Store 'As Outlook.Store
 Dim Stores 'As Outlook.Stores
 Dim objFolder 'As Outlook.Folder
  
 Set objOutlook = CreateObject("Outlook.Application")
 Set Session = objOutlook.Session
 Set Stores = Session.Stores
  
 For Each Store In Stores
  
 If Store.ExchangeStoreType = 3 then
    Set objFolder = store.GetRootFolder
    Session.RemoveStore objFolder
 End If
  
 Next

Comments

  • Anonymous
    January 01, 2003
    Work with pst files by outlook 2007 ost repair www.ostrepairtoolbox.com

  • Anonymous
    May 30, 2012
    The comment has been removed

  • Anonymous
    June 01, 2012
    Odd... Do you have outlook installed on your pc? Script was tested on outlook 2003 and 2010 so something must be going on in your environment...

  • Anonymous
    August 17, 2012
    It works except it skipped every other PST file

  • Anonymous
    September 05, 2012
    This script uses a For Each-statement to traverse the list, but inside the loop items may be removed. The element after the deleted one will never be tested for deletion. See this page for a better script: techblog.se/.../script-fr-att-stnga-alla-ppna-pst-filer

  • Anonymous
    April 18, 2015
    this is cool but only runs when outlook is closed