VBA script to identify duplictae emails in Outlook Email Inbox 2010

Our Outlook 2010 has been filled with duplicate emails.  Some time back the Outlook just started downloading emails already received dating from now until a year ago.  Though we think we have that specific problem solved, we are looking for a script that would identify the duplicates.

Greatly appreciated.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bill PrewCommented:
Take a look at the freeware version of this tool and see if it might meet your need.  They work pretty well, but to get to some of the more advanced features sometimes requires purchase.  But their free utilities can be useful if you aren't doing anything too complex.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rayluvsAuthor Commented:

Have you tried it? Is it safe?
Bill PrewCommented:

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

rayluvsAuthor Commented:
Thank you, will try.
rayluvsAuthor Commented:
WoW!  that was super quick!  Went thru a folder with over 4000 emails and in a snap identified it!

Thank you very much!!!!!
rayluvsAuthor Commented:
rayluvsAuthor Commented:
Hi, just closed the question, but do you know what does  the apps compare to identify as "Duplicate"?
Neil FlemingConsultant and developerCommented:
Here's a routine I wrote some time ago when I had the same problem. It assumes that duplicates will have identical timestamps and identical subjects. If you're nervous about deleting the apparent duplicates in testing, then if you comment out line 33 in the code, and uncomment line 32 it will flag duplicates as action items for today, rather than just deleting them.

Hope this is useful

Sub deDupe(Optional aFolder As Folder)
'removes or marks duplicates

Dim subFolder As Folder
Dim allItems As Items
Dim thisItem As MailItem, prevItem As MailItem
Dim dPrev As Date
Dim i As Long, iPrevsize As Long, iDelCount As Long
Dim sPrev As String
On Error Resume Next
If (aFolder Is Nothing) Then
Set ns = Application.GetNamespace("MAPI")
Set exp = ActiveExplorer
Set aFolder = exp.Selection.parent.CurrentFolder
Set rootFolder = aFolder
End If
Debug.Print "Scanning " & aFolder.FolderPath & "..."

Set allItems = aFolder.Items
allItems.Sort "ReceivedTime", False

If allItems.Count > 0 Then
        'iterate backwards through items:
        For i = allItems.Count To 1 Step -1
            If TypeName(allItems(i)) = "MailItem" Then
            Set thisItem = allItems(i)
                If (dPrev = thisItem.ReceivedTime) And (sPrev = thisItem.Subject) Then
                'Debug.Print thisItem.Subject
                'thisItem.MarkAsTask olMarkToday
                iDelCount = iDelCount + 1
                dPrev = thisItem.ReceivedTime
                iPrevsize = thisItem.Size
                sPrev = thisItem.Subject
                End If
            End If
    'end if items found in folder:
End If
Debug.Print (iDelCount & " duplicate items found.")
    'iterate folder structure
For Each subFolder In aFolder.Folders
deDupe subFolder

If aFolder = rootFolder Then
EmptyDeletedItems aFolder
Debug.Print "Finished DeDupe"
End If
End Sub

Open in new window

Neil FlemingConsultant and developerCommented:
ah.. looks like the freeware sorted you out already...
Bill PrewCommented:
I think if you check the "use custom fields" the free ware version uses "Subject, Message Text, Sender, Recipients and Attachments".  But with that option unchecked it looks at the internal email "ID" of each message to identify duplicates.  I will admit the freeware versions are light on documentation sometimes, but they typically work well and are simple enough to understand.  There are forums where you can post questions, but not sure how active they are, haven't used those.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.