

This script also takes into account the fact that some items use an HTMLBody for the full message definition, and others don't have that property. 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. Create a CSV file - stored under the path in StrPath to create a external reference to Outlook of the emails that have been moved.Moved (rather than delete) any duplicates into a sub-folder ( removed items) of the folder being processed.Checks duplicates on the base of Subject, Sender, CreationTime and Size.Provides users with a prompt to select the folder to process.
