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.
rayluvsAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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 PrewIT / Software Engineering ConsultantCommented:
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.



»bp

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:
Hi,

Have you tried it? Is it safe?
Bill PrewIT / Software Engineering ConsultantCommented:
Yes.


»bp
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

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:
Thanx!
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
                thisItem.Delete
                iDelCount = iDelCount + 1
                Else
                dPrev = thisItem.ReceivedTime
                iPrevsize = thisItem.Size
                sPrev = thisItem.Subject
                End If
            
            End If
        Next
    DoEvents
    '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
Next

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 PrewIT / Software Engineering ConsultantCommented:
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.


»bp
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
Outlook

From novice to tech pro — start learning today.