Results 1 to 10 of 10

Thread: Outlook VBA e-mail count per day

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #8
    The collection processes the sub folders. If you run the following macro, which uses the same process, in Outlook it will list all the sub folders for the selected folder in the immediate window of the VBA editor (Ctrl+G). This will be much faster than the mail count.

    Sub ListFolders()
    
    Dim cFolders As Collection
    Dim olFolder As Outlook.Folder
    Dim SubFolder As Folder
    Dim olNS As Outlook.NameSpace
    Set cFolders = New Collection
    Set olNS = GetNamespace("MAPI")
    cFolders.Add olNS.PickFolder
    MsgBox "This could take a while to process!"
    Do While cFolders.Count > 0
        Set olFolder = cFolders(1)
        cFolders.Remove 1
        Debug.Print olFolder.Name
        For Each SubFolder In olFolder.folders
            cFolders.Add SubFolder
        Next SubFolder
        DoEvents
    Loop
    Set cFolders = Nothing
    Set olFolder = Nothing
    Set SubFolder = Nothing
    Set olNS = Nothing
    End Sub
    Last edited by Aussiebear; 04-23-2023 at 04:54 PM. Reason: Adjusted the whitespace
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •