Skip to content

Instantly share code, notes, and snippets.

@swbuehler
Created September 9, 2016 15:48
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 swbuehler/8c408226060ddc8475372ee64b43d197 to your computer and use it in GitHub Desktop.
Save swbuehler/8c408226060ddc8475372ee64b43d197 to your computer and use it in GitHub Desktop.
Dedupe(): Removes duplicate emails from currently active Outlook folder by comparing the Sent Dates of emails and removing emails with duplicate sent dates.
Sub dedupe()
Dim ol As New Outlook.Application
Dim dates As Collection
Dim mbox As Outlook.Folder
Set dates = New Collection
Set mbox = ol.ActiveExplorer.CurrentFolder
For Each msg In mbox.Items
msgDate = msg.SentOn
Debug.Print msgDate
flag = 0
For i = 1 To dates.Count
If msgDate = dates.Item(i) Then
msg.Delete
flag = 1
End If
Next i
If flag = 0 Then dates.Add msg.SentOn
Next msg
Set dates = New Collection
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment