Search code examples
vbscriptoutlookoutlook-2010

Checking the folder type


I loop through each folder of my Outlook store to check the folder type by retrieving all default folders and comparing their EntryID.

Public Function GetFolderTypeName(objFolder)
 Dim objType, objDefaultFolder

 'dctValidFolders is a dictionary of default folders type
 For Each objType in dctValidFolders
  Set objDefaultFolder = objMAPI.GetDefaultFolder(dctValidFolders.Item(objType))
  If objFolder.EntryID = objDefaultfolder.EntryID Then
    Set objDefaultfolder = Nothing
    GetFolderTypeName = objType
    Exit Function
  End If
 Next
End Function

Now, I have a mailbox that has more than one folder of type contacts.

Is there another way to know the folder type?


Solution

  • There was in fact, check

    folder.DefaultItemType 
    

    This will return an item type , like olMailItem, and depending on that you can "assume" the folder type.