Skip to content

Instantly share code, notes, and snippets.

@konijn
Created May 20, 2021 09:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save konijn/59d31df47f316ee3ecab7ed37565260e to your computer and use it in GitHub Desktop.
Save konijn/59d31df47f316ee3ecab7ed37565260e to your computer and use it in GitHub Desktop.
Count individual message subjects
Option Explicit
Public Sub processMessages()
Dim objOL As Outlook.Application
Dim currentExplorer As Explorer
Dim Selection As Selection
Dim obj As Object
Dim dict As Object
Set objOL = Outlook.Application
Set currentExplorer = objOL.ActiveExplorer
Set Selection = currentExplorer.Selection
Set dict = CreateObject("Scripting.Dictionary")
For Each obj In Selection
'Loop over every selected email
With obj
If dict.exists(.Subject) Then
dict(.Subject) = dict(.Subject) + 1
Else
dict(.Subject) = 1
End If
End With
Next
Dim key As Variant
For Each key In dict.Keys
Debug.Print key, dict(key)
Next key
'Set Session = Nothing
Set currentExplorer = Nothing
Set obj = Nothing
Set Selection = Nothing
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment