Sign in to follow this  

outlook problem

Recommended Posts


I need to check the total number of items in a folder frequently, But there are a lot of subfolders under this folder. The total number of items which shows in the right of the folder doesn't contain the number of items in its subfolders. So I need to count them by plusing them all by myself.

So my question is that can I just set the outlook to show the total number of items in a folder inculding its subfolders.  How to do that ?


Share this post

Link to post
Share on other sites

Yes, you can write VBA codes to do that for you. I just find a macro which may be close to  what you need.


Sub CountItems()
    Dim objMainFolder As Outlook.Folder
    Dim lItemsCount As Long
    'Select a folder
    Set objMainFolder = Outlook.Application.Session.PickFolder
    If objMainFolder Is Nothing Then
       MsgBox "You choose select a valid folder!", vbExclamation + vbOKOnly, "Warning for Pick Folder"
       'Initialize the total count
       lItemsCount = 0
       Call LoopFolders(objMainFolder, lItemsCount)
    End If
    'Display a message for the total count
    MsgBox "There are " & lItemsCount & " items in the " & objMainFolder.Name & " folder Including its subfolders.", vbInformation, "Count Items"
End Sub

Sub LoopFolders(ByVal objCurrentFolder As Outlook.Folder, lCurrentItemsCount As Long)
    Dim objSubfolder As Outlook.Folder
    lCurrentItemsCount = lCurrentItemsCount + objCurrentFolder.Items.Count
    'Process all folders and subfolders recursively
    If objCurrentFolder.Folders.Count Then
       For Each objSubfolder In objCurrentFolder.Folders
           Call LoopFolders(objSubfolder, lCurrentItemsCount)
    End If
End Sub

And here is the link of the macro, tou can see if  it helps


Good luck

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this