Within Microsoft Outlook for each folder you will see a count of the number of unread items. It is possible to switch this figure to show a count of all items within a folder.



This is useful for finding a mismatch between the source and destination mailboxes:-


For counting the total numbers of all items in all folders, please apply below VBA code in Outlook.


Please note, this script is run at your own risk and any custom settings on folders or sub-folders will be over written. This script will switch all mailboxes within outlook so you may wish to detach some mailboxes before running the script.


1. Press Alt + F11 keys simultaneously to open the Microsoft Visual Basic for Applications window whilst in outlook.


2. For the project,  Click Insert > Module, and then paste below VBA code into the new opening Module window.




Sub ShowTotalInAllFolders()

Dim oStore As Outlook.Store

Dim oRoot As Outlook.Folder


On Error Resume Next


For Each oStore In Application.Session.Stores

Set oRoot = oStore.GetRootFolder

ShowTotalInFolders oRoot

Next

End Sub


Private Sub ShowTotalInFolders(ByVal Root As Outlook.Folder)

Dim oFolder As Outlook.Folder


On Error Resume Next


If Root.Folders.Count > 0 Then

For Each oFolder In Root.Folders

oFolder.ShowItemCount = olShowTotalItemCount

ShowTotalInFolders oFolder

Next

End If

End Sub




3. Press the F5 key or click the Run button to run this VBA.


You may need to set macro security to low during testing.


To check your macro security in Outlook 2010 or 2013, go to File, Options, Trust Center and open Trust Center Settings, and change the Macro Settings. In Outlook 2007 and older, it’s at Tools, Macro Security.


Comparing Outlook with the destination


Once the above script has been run you are able to compare outlook with the mailbox details view in migration monster (or outlook on the destination by running this script against outlook linked to the destination mailbox).






To return all folders back to show only unread messages count please run the following scripts




Sub ShowTotalInAllFolders()

Dim oStore As Outlook.Store

Dim oRoot As Outlook.Folder


On Error Resume Next


For Each oStore In Application.Session.Stores

Set oRoot = oStore.GetRootFolder

ShowTotalInFolders oRoot

Next

End Sub


Private Sub ShowTotalInFolders(ByVal Root As Outlook.Folder)

Dim oFolder As Outlook.Folder


On Error Resume Next


If Root.Folders.Count > 0 Then

For Each oFolder In Root.Folders

oFolder.ShowItemCount = olShowUnreadItemCount

ShowTotalInFolders oFolder

Next

End If

End Sub