none
show number of contacts in main contacts folder AND in contacts sub-folders RRS feed

  • Question

  • Hi

    Is there a way to find number of contacts in my contacts folder to show in an app

    Also need to be able to find number of contacts in several other contact folders which are sub-folders of my main contacts folder

    Thanks


    Darren Rose

    Monday, October 27, 2014 8:53 PM

Answers

  • Use folder.Items.Count property to get the number of contacts in the folder. You need to iterate over all folders and summarize results.

    Note, a folder may contain various types of items. You need to use the Restrict method of the Items class to get only contact items.

    • Marked as answer by wingers Monday, October 27, 2014 9:27 PM
    Monday, October 27, 2014 9:06 PM
  • cancel that request - worked it out for myself after fiddling around

    Dim objFolder_NoContactFor2YearsTemp As Outlook.MAPIFolder = objNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts).Folders("Business").Folders("Business3")
            


    Darren Rose

    • Marked as answer by wingers Monday, October 27, 2014 10:34 PM
    Monday, October 27, 2014 10:34 PM

All replies

  • Use folder.Items.Count property to get the number of contacts in the folder. You need to iterate over all folders and summarize results.

    Note, a folder may contain various types of items. You need to use the Restrict method of the Items class to get only contact items.

    • Marked as answer by wingers Monday, October 27, 2014 9:27 PM
    Monday, October 27, 2014 9:06 PM
  • Use folder.Items.Count property to get the number of contacts in the folder. You need to iterate over all folders and summarize results.

    Note, a folder may contain various types of items. You need to use the Restrict method of the Items class to get only contact items.


    excellent thanks - that works perfectly for me

    Darren Rose

    Monday, October 27, 2014 9:27 PM
  • one issue - works fine for main contacts folder and have worked out how to do the sub-folder - but I have one sub-sub-folder which I can't get working - any ideas

     Dim objOutlook As Outlook._Application = New Outlook.Application()
            Dim objNameSpace As Outlook._NameSpace = objOutlook.Session
            Dim objFolder_MainContacts As Outlook.MAPIFolder = objNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts)
            Dim objContacts_MainContacts As Outlook._Items = objFolder_MainContacts.Items
            Dim objFolder_Distance As Outlook.MAPIFolder = objNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts).Folders("Distance")
            Dim objContacts_Distance As Outlook._Items = objFolder_Distance.Items

    i.e. my folder layout is like this - I can get contacts, business and business2, but not business3

    Contacts
         Business
              Business3
         Business2


    Darren Rose

    Monday, October 27, 2014 10:16 PM
  • cancel that request - worked it out for myself after fiddling around

    Dim objFolder_NoContactFor2YearsTemp As Outlook.MAPIFolder = objNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts).Folders("Business").Folders("Business3")
            


    Darren Rose

    • Marked as answer by wingers Monday, October 27, 2014 10:34 PM
    Monday, October 27, 2014 10:34 PM