I want to count how many emails are in a folder (including sub folders) and outlook is not providing it. If I have a folder called '2020' whats some good code to tell me how many emails total are in that folder and subfolders?
Thanks
I want to count how many emails are in a folder (including sub folders) and outlook is not providing it. If I have a folder called '2020' whats some good code to tell me how many emails total are in that folder and subfolders?
Thanks
You will need a macro
Sub CountContents() Dim cFolders As Collection Dim olFolder As Outlook.Folder Dim SubFolder As Folder Dim olNS As Outlook.NameSpace Dim lngCount As Long: lngCount = 0 Set cFolders = New Collection Set olNS = GetNamespace("MAPI") cFolders.Add olNS.PickFolder Do While cFolders.Count > 0 Set olFolder = cFolders(1) cFolders.Remove 1 lngCount = lngCount + olFolder.items.Count For Each SubFolder In olFolder.folders cFolders.Add SubFolder Next SubFolder Loop MsgBox lngCount & " items" lbl_Exit: Set olFolder = Nothing Set SubFolder = Nothing Exit Sub End Sub
Graham Mayor - MS MVP (Word) 2002-2019
Visit my web site for more programming tips and ready made processes
http://www.gmayor.com