Messaging and beyond!

Tales of an MS Exchange PFE

Scripting: Remove all PST files in an outlook profile

Scripting: Remove all PST files in an outlook profile

  • Comments 6
  • Likes

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
  • I get an error line 10 char 1 Object doesn't support this property or method: 'Stores'

    Code 800a01b6

  • 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...

  • It works except it skipped every other PST file

  • 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:

  • Work with pst files by outlook 2007 ost repair

  • this is cool but only runs when outlook is closed

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment