
Once the date changes, you know you'll never see another email with the prior date, therefore, they won't be duplicates, so you can clear your dictionary on each date change. There's no need to maintain a giant dictionary of every email you've seen if you are processing emails in a deterministic order (e.g. Here's a script that takes advantage of sorting emails to check for duplicates much more efficiently. MsgBox "duplicate items were removed to ""removed items""", vbCritical, "See " & strPath & " for details"

ObjTF.WriteLine Replace(objItem.Subject, ", ", Chr(32)) StrCheck = Replace(strCheck, ", ", Chr(32)) StrCheck = objItem.Subject & "," & objItem.Body & "," If olFolder2 Is Nothing Then Set olFolder2 = ("removed items")įor lngCnt = To 1 Step -1 Set olFolder2 = olFolder.Folders("removed items") Set objTF = objFSO.CreateTextFile(strPath) Set objFSO = CreateObject("scripting.filesystemobject") Set objDic = CreateObject("scripting.dictionary") Tested on Outlook 2016 Const strPath = "c:\temp\deleted msg.csv" I have changed the test to subject and body Updated: Checking for size surprisingly missed a number of dupes, even for otherwise identical mail items.

Checks duplicates on the base of Subject, Sender, CreationTime and Size.

