none
Outlook read PST Subfolder (not Standard Folder) RRS feed

  • Question

  • Hi,
    I'm looking for a way to read out PST or OST files in Outlook.
    I can so far read the individual PST names and directories etc, and recognize.
    But how do I read these PST subdirectories (e.g. "Kunden-A-D" or "Kunden-I-Z" )?
    Everything under the inbox is I can read and access it.
    How do I get to the others now?

    Does somebody has any idea

    Best Regards

    Bernd

    Wednesday, March 15, 2017 9:47 AM

Answers

  • Hello Bernd,

    They are stores. You can use the Stores property of the Namespace class which returns a Stores collection object that represents all the Store objects in the current profile. You can use the Stores and Store objects to enumerate all folders and search folders on all stores in the current session.

    Sub EnumerateFoldersInStores() 
     
     Dim colStores As Outlook.Stores 
     
     Dim oStore As Outlook.Store 
     
     Dim oRoot As Outlook.Folder 
     
     
     
     On Error Resume Next 
     
     Set colStores = Application.Session.Stores 
     
     For Each oStore In colStores 
     
     Set oRoot = oStore.GetRootFolder 
     
     Debug.Print (oRoot.FolderPath) 
     
     EnumerateFolders oRoot 
     
     Next 
     
    End Sub 
     
     
     
    Private Sub EnumerateFolders(ByVal oFolder As Outlook.Folder) 
     
     Dim folders As Outlook.folders 
     
     Dim Folder As Outlook.Folder 
     
     Dim foldercount As Integer 
     
     
     
     On Error Resume Next 
     
     Set folders = oFolder.folders 
     
     foldercount = folders.Count 
     
     'Check if there are any folders below oFolder 
     
     If foldercount Then 
     
     For Each Folder In folders 
     
     Debug.Print (Folder.FolderPath) 
     
     EnumerateFolders Folder 
     
     Next 
     
     End If 
     
    End Sub


    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    • Marked as answer by Bernd Riemke Wednesday, March 15, 2017 3:07 PM
    Wednesday, March 15, 2017 11:22 AM

All replies

  • Hello Bernd,

    They are stores. You can use the Stores property of the Namespace class which returns a Stores collection object that represents all the Store objects in the current profile. You can use the Stores and Store objects to enumerate all folders and search folders on all stores in the current session.

    Sub EnumerateFoldersInStores() 
     
     Dim colStores As Outlook.Stores 
     
     Dim oStore As Outlook.Store 
     
     Dim oRoot As Outlook.Folder 
     
     
     
     On Error Resume Next 
     
     Set colStores = Application.Session.Stores 
     
     For Each oStore In colStores 
     
     Set oRoot = oStore.GetRootFolder 
     
     Debug.Print (oRoot.FolderPath) 
     
     EnumerateFolders oRoot 
     
     Next 
     
    End Sub 
     
     
     
    Private Sub EnumerateFolders(ByVal oFolder As Outlook.Folder) 
     
     Dim folders As Outlook.folders 
     
     Dim Folder As Outlook.Folder 
     
     Dim foldercount As Integer 
     
     
     
     On Error Resume Next 
     
     Set folders = oFolder.folders 
     
     foldercount = folders.Count 
     
     'Check if there are any folders below oFolder 
     
     If foldercount Then 
     
     For Each Folder In folders 
     
     Debug.Print (Folder.FolderPath) 
     
     EnumerateFolders Folder 
     
     Next 
     
     End If 
     
    End Sub


    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    • Marked as answer by Bernd Riemke Wednesday, March 15, 2017 3:07 PM
    Wednesday, March 15, 2017 11:22 AM
  • Many Thanks!

    Now it works :-)

    Best Regards

    Bernd

    Wednesday, March 15, 2017 3:08 PM