none
Outlook addin how detect hidden folders in Exchange envrionnement RRS feed

  • Question

  • hi,

     

    I need to browse all folders but not the hidden folders. How can I know which is hidden ?

     

    Thanks

    Tuesday, May 24, 2011 11:00 AM

Answers

  • If you are using the Outlook object model any folders exposed under the NameSpace object (NameSpace.Folders) are all visible folders.
     
    For Outlook 2007 and above, you can use PropertyAccessor on a Folder to check the hidden status. If the folder is hidden the property PR_ATTR_HIDDEN (a PT_BOOLEAN) will be set to true. The DASL property tag for that property is (string tag, not a URL): "http://schemas.microsoft.com/mapi/proptag/0x10F4000B".

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Minoc" <=?utf-8?B?TWlub2M=?=> wrote in message news:4df831c7-5dc4-4c51-9d7e-0da8ef865f11...

    hi,

     

    I need to browse all folders but not the hidden folders. How can I know which is hidden ?

     

    Thanks


    Ken Slovak MVP - Outlook
    Tuesday, May 24, 2011 1:33 PM
  • If you compare EntryID's make sure to do it using the NameSpace.CompareEntryIDs() method. That accounts for differences in id's whether you get the short-term or long-term EntryID if Exchange is used, or in other cases where a simple equality test won't work correctly.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Minoc" <=?utf-8?B?TWlub2M=?=> wrote in message news:359b06ec-4aed-4813-ab62-7c1f948a9888...

    I found a solution : 

    I just test if the folder entryID is not equals to the oApp.Session.getDefaultFolder(Outlook.OlDefaultFolders.olFolderConflicts)..EntryID;

    same for the other folders.

     

    Thank you for your help,

     

    Kilian Minoc


    Ken Slovak MVP - Outlook
    Wednesday, May 25, 2011 1:16 PM

All replies

  • If you are using the Outlook object model any folders exposed under the NameSpace object (NameSpace.Folders) are all visible folders.
     
    For Outlook 2007 and above, you can use PropertyAccessor on a Folder to check the hidden status. If the folder is hidden the property PR_ATTR_HIDDEN (a PT_BOOLEAN) will be set to true. The DASL property tag for that property is (string tag, not a URL): "http://schemas.microsoft.com/mapi/proptag/0x10F4000B".

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Minoc" <=?utf-8?B?TWlub2M=?=> wrote in message news:4df831c7-5dc4-4c51-9d7e-0da8ef865f11...

    hi,

     

    I need to browse all folders but not the hidden folders. How can I know which is hidden ?

     

    Thanks


    Ken Slovak MVP - Outlook
    Tuesday, May 24, 2011 1:33 PM
  • Thanks, but I tried to check this property but for an invisible folder the value of this property tag is set to false. 

    foreach (Outlook.Folder fold in folders)
          {
            if (fold.DefaultItemType == Microsoft.Office.Interop.Outlook.OlItemType.olMailItem)
            {
              if (fold.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x10F4000B") != true)
              {
                nb += fold.Items.Count;
                nb += recurseNbItemsFolder(fold.Folders);
              }
            }
          }

    Tuesday, May 24, 2011 3:06 PM
  • I don't get that at all. I get true for a hidden folder using PropertyAccessor() with that property, false for visible folders.
     
    Here is some Outlook VBA test code I used to test this. It worked perfectly in identifying hidden folders in my Outlook profile:
     
    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
        Dim bHidden As Boolean
       
        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
                bHidden = Folder.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x10F4000B")
                Debug.Print (Folder.FolderPath), "Folder hidden = " & bHidden
               
                EnumerateFolders Folder
            Next
        End If
    End Sub

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Minoc" <=?utf-8?B?TWlub2M=?=> wrote in message news:c02b254b-6b13-4037-b65a-e4e6939d6eaa...

    Thanks, but I tried to check this property but for an invisible folder the value of this property tag is set to false. 

    foreach (Outlook.Folder fold in folders)
       {
        if (fold.DefaultItemType == Microsoft.Office.Interop.Outlook.OlItemType.olMailItem)
        {
         if (fold.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x10F4000B") != true)
         {
          nb += fold.Items.Count;
          nb += recurseNbItemsFolder(fold.Folders);
         }
        }
       }


    Ken Slovak MVP - Outlook
    Tuesday, May 24, 2011 5:47 PM
  • It's didn't worked. 

    This 3 folders are hidden but the propertyAccessor return false for the propTag "http://schemas.microsoft.com/mapi/proptag/0x10F4000B" :

    - sync issues

    - Conflicts

    - Local faillures

    - Server faillures

     

    I want to ignore this 4 folders when I browse all mailItems in an Exchange Store.

    Thanks

    Wednesday, May 25, 2011 9:16 AM
  • I found a solution : 

    I just test if the folder entryID is not equals to the oApp.Session.getDefaultFolder(Outlook.OlDefaultFolders.olFolderConflicts).EntryID;

    same for the other folders.

     

    Thank you for your help,

     

    Kilian Minoc

    Wednesday, May 25, 2011 11:03 AM
  • None of those folders are hidden folders.
     
    That's why that property isn't working for them. If you can see the folders in the navigation pane they are not hidden.
     
    An example of a hidden folder in Outlook 2010 would be the Quick Step Settings folder, or the Conversation Action Settings folder.
     
    Those folders have the property set to true, and are hidden.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Minoc" <=?utf-8?B?TWlub2M=?=> wrote in message news:ffac10ee-731a-493e-b10c-7549bc65739c...

    It's didn't worked. 

    This 3 folders are hidden but the propertyAccessor return false for the propTag "http://schemas.microsoft.com/mapi/proptag/0x10F4000B" :

    - sync issues

    - Conflicts

    - Local faillures

    - Server faillures

     

    I want to ignore this 4 folders when I browse all mailItems in an Exchange Store.

    Thanks


    Ken Slovak MVP - Outlook
    Wednesday, May 25, 2011 1:16 PM
  • If you compare EntryID's make sure to do it using the NameSpace.CompareEntryIDs() method. That accounts for differences in id's whether you get the short-term or long-term EntryID if Exchange is used, or in other cases where a simple equality test won't work correctly.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Minoc" <=?utf-8?B?TWlub2M=?=> wrote in message news:359b06ec-4aed-4813-ab62-7c1f948a9888...

    I found a solution : 

    I just test if the folder entryID is not equals to the oApp.Session.getDefaultFolder(Outlook.OlDefaultFolders.olFolderConflicts)..EntryID;

    same for the other folders.

     

    Thank you for your help,

     

    Kilian Minoc


    Ken Slovak MVP - Outlook
    Wednesday, May 25, 2011 1:16 PM