Created
September 9, 2016 15:48
-
-
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.
This file contains 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
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