Created
May 20, 2021 09:12
-
-
Save konijn/59d31df47f316ee3ecab7ed37565260e to your computer and use it in GitHub Desktop.
Count individual message subjects
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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