How to Remove Duplicates from Outlook 2016 or Outlook 365

Let's Get Rid of These Duplicates on Outlook!

Outlook Duplicates
It happens — duplicates on Outlook. Mostly when you tried to backup and restore your Outlook files, or simply have switched servers, or whatsoever.

Outlook maybe the worst and outdated email client in the worlds, as it has no duplicate filter. That’s why you have take things into your own hands.

If you are already tried or read about other solutions, let me spare your time. These methods below don’t work:

  • Doesn’t work: Remove Duplicates by Export/Import PST Files
    You may have realized that when you export outlook data as PST, there is a feature asking you that you don’t export/import duplicates. Well, guess what. Outlook does it anyway. Didn’t help at all. I have exported without duplicates. Then imported without duplicates. And what I got in the end? Duplicates! Thanks, Microsoft for wasting my time!
  • Doesn’t work for me: Buy a tool that does it for you?
    Sure, why not spent $40 or more to remove duplicates — a standard feature on almost every decent mailer has. Thanks, but no thanks.

This does work — in 5 minutes!

Below is the solution. With only one simple action, you can make duplicates disappear — it’s like a magic trick!

Step 1: Preparations

Go to File at the menu and click at “Options”, then go to “Trust Center”, click “Trust Center Settings”, in there click “Macro Settings” and select “Notification for all macros” like this:

How to remove folders on Outlook

Step 2: Copy & Paste A Script

Now you are going to write a script — or better: You will copy & paste the script I’m providing below. Don’t be scared — it’s dead easy! I’ll tell you exactly how.

Press ALT+F11.

If a security warning pops up called “Microsoft Outlook Security Notice”, just press “Enable Macros” to continue.

Microsoft Outlook Security Notice

A new windows should open up called “Microsoft Visual Basic for Applications” that should look like this — don’t be scared. This is a lifesaver!

Microsoft VBA

All you have to do now is to go to “Microsoft Outlook Objects”, press right mouse button, then go to “Insert” and then “Module”. Look below, it’s super easy:

Microsoft VBA Insert Module

A new window should appear on the left side. Now put this code in there:

Sub RemoveDuplicateItems()
    Dim objFolder As Folder
    Dim objDictionary As Object
    Dim i As Long
    Dim objItem As Object
    Dim strKey As String

    Set objDictionary = CreateObject("scripting.dictionary")
    'Select a source folder
    Set objFolder = Outlook.Application.Session.PickFolder

    If Not (objFolder Is Nothing) Then
       For i = objFolder.Items.Count To 1 Step -1
           Set objItem = objFolder.Items.Item(i)
 
           Select Case objFolder.DefaultItemType
                  'Check email subject, body and sent time
                  Case olMailItem
                       strKey = objItem.Subject & "," & objItem.Body & "," & objItem.SentOn
                  'Check appointment subject, start time, duration, location and body
                  Case olAppointmentItem
                       strKey = objItem.Subject & "," & objItem.Start & "," & objItem.Duration & "," & objItem.Location & "," & objItem.Body
                  'Check contact full name and email address
                  Case olContactItem
                       strKey = objItem.FullName & "," & objItem.Email1Address & "," & objItem.Email2Address & "," & objItem.Email3Address
                  'Check task subject, start date, due date and body
                  Case olTaskItem
                       strKey = objItem.Subject & "," & objItem.StartDate & "," & objItem.DueDate & "," & objItem.Body
           End Select
 
           strKey = Replace(strKey, ", ", Chr(32))
 
           'Remove the duplicate items
           If objDictionary.Exists(strKey) = True Then
              objItem.Delete
           Else
              objDictionary.Add strKey, True
           End If
       Next i
    End If
End Sub

This is how it should look like on your end:

Duplicates Remove Script Outlook

Step 3: Run that script!

That’s it! Run the script and duplicates inside this folder will disappear. How to run the script? Easy — see that “Run” feature on the menu… it’s this one here:

How to run VBS Script

Now it will ask which folder. Select the folder you want the duplicates to be removed from.

Done!

If you liked this, please give me a nice comment on the bottom of the page. Thank you!

VPN Software Test 2020
Top VPN Tools 2020: Tested & Reviewed Don't Let Them Spy on Your Data!

LIST OF TOP VPNs

Top Antivirus Tools | Update May, 2020

1
SYMANTEC Norton Security Antivirus 2020
Norton Antivirus 2020
Review 5.0

starts at $29.99

Order now
Norton Antivirus is one of our review winners in 2020. No other antivirus software offers such impressive virus protection in the market right now. This may change in the future as the market is constantly changing.
2
AVG Internet Security 2020
AVG Antivirus Internet Security
Review 5.0

starts at $49.99

Order now
In 2020 AVG began offering unlimited install features for their antivirus software. For everyone, but especially families, this is one of the best bargains of the year. The interface couldn’t be any easier to use, and the malware protection is solid.
3
Avast Pro Antivirus 2020
AVG Antivirus Internet Security 2020
Review 4.9

starts at $47.99

Order now
One of the advantages of Avast 2020 is not just it’s reliability and broad antivirus protection but also the price. At only $47.99, it’s one of the most affordable deals you can find among reputable antivirus tools.
4
Bullguard Antivirus 2020
Bullguard Antivirus
Review 4.7

starts at $23.99

Order now
Bullguard may not be as famous as the big market players, but it’s unequivocally one of the best antivirus software in the world. It was developed by hackers and computer enthusiasts from a small UK company. As the price suggests, they are driven by passion, not for as much profit as other bigger competitors.
5
Panda Security 2020
Panda Security 2020
Review 4.7

starts at $35.39

Order now
Panda is not only the cheapest, but is actually one of a kind: They invented the first artificial intelligent virus protection in the world that recognizes unknown viruses. It works so well that they became extremely popular in Europe, and are being praised by hackers.
6
Kaspersky Antivirus 2020
Kaspersky Antivirus 2020
Review 4.5

starts at $29.99

Order now
With over 400 million users, over 20 years of experience, and 270,000 corporate clients, Kaspersky Lab technologies is a strong cybersecurity company. This company offers an array of powerful products such as Kaspersky Total Security 2020, Kaspersky Anti-Virus, Kaspersky Internet Security and more.
7
McAfee Antivirus 2020
McAfee Antivirus 2020
Review 4.4

starts at $44.99

Order now
McAfee has been around for more than 30 years, making them one of the oldest virus protection companies on the market. Due to restructuring of the company over the last years, the company has successfully created a new product fit to satisfy customers in 2020.
8
Avira Antivirus Pro 2020
Avira Antivirus
Review 3.0

starts at $30.99

Order now
AVIRA Antivirus is one of the most popular virus protection software. They’ve been famous for years for their free antivirus offering. The paid version is as good as the free version but without ads. For only $30.99, they make switching to the professional version worth it.

Our reviews are compliant with FTC 16 CFR Part 255
As an Amazon Associate I earn from qualifying purchases

Recent Articles About Software SHOW ALL ARTICLES

22 comments for “How to Remove Duplicates from Outlook 2016 or Outlook 365

  1. Bruce Fry,
    May 21, 2018 at 2:21 pm

    How do you remove duplicate CONTACTS in Outlook?

    I see your solution for email but contacts are as big a problem if not bigger.

  2. Gordon Collins,
    June 4, 2018 at 3:33 pm

    That’s brilliant. Works a treat. Thanks

  3. Andrew,
    July 19, 2018 at 1:33 am

    Tried your macro and got the following error:

    Run-time error ‘438’:

    Object doesn’t support this property or method

  4. wex,
    July 19, 2018 at 7:14 am

    Quite good script. One thing should be polished, it should be able delete also subfolders and subsbufolders.. imagine very complicated mail tree hierarchy, now you need to specify each folder individualy.

  5. Matias,
    July 31, 2018 at 10:12 am

    Got the same error:
    “Run-time error ‘438’:
    Object doesn’t support this property or method”

  6. RA,
    July 31, 2018 at 2:38 pm

    Andrew
    July 19, 2018 at 1:33 am
    Tried your macro and got the following error:

    Run-time error ‘438’:

    Object doesn’t support this property or method

    I had the same issue as Andrew ^^^ :'(

  7. Steve Ormand,
    September 12, 2018 at 8:32 pm

    Got the same error:
    “Run-time error ‘438’:
    Object doesn’t support this property or method”

  8. Digitalwelt Team,
    September 13, 2018 at 6:37 am

    Hey guys, quick question – I want to help. That run-time error you’re getting: On which Windows and Office version is it happening?

  9. Charles DiGiovanna,
    October 3, 2018 at 6:40 am

    Office365 Windows 10
    Works on PST but not OST file
    strKey = objItem.Subject & “,” & objItem.Body & “,” & objItem.SentOn

  10. Cesar,
    December 27, 2018 at 5:14 pm

    Same error here, I did some research and apparently is because when looping, the macro finds other types of objects not defined in the “Select Case” procedure, such as meetings or read receipts… does anyone know how to fix that?

  11. Brian,
    January 7, 2019 at 11:40 pm

    Any luck with finding a fix for this “Run-time error ‘438’”
    also running windows 10 and office 16 through 365

    the debug option highlights and points to this line
    strKey = objItem.Subject & “,” & objItem.Body & “,” & objItem.SentOn

  12. Peter,
    March 9, 2019 at 4:01 am

    I tried both the built-in Outlook 2016 feature (which was useless) and commercial cleaners (which charged me money and then did *incorrect* duplicate removal) … it’s crazy, your little script is *better* …

    I’ve expanded the code a bit – i’m processing PST files with over 10,000 emails. I don’t know VBA well so hopefully this doesn’t do bad things, but it is working for me – gives an continuous update, and ‘yields’ cpu time back to the OS and Outlook so everything doesn’t all freeze. For email comparison, i also added sender email as part of your dict key, to be even more conservative.

    Sub RemoveDuplicateItems()
    Dim objFolder As Folder
    Dim objDictionary As Object
    Dim i As Long
    Dim deleted_count As Long
    Dim processed_count As Long
    Dim objItem As Object
    Dim strKey As String
    Dim xx As Long

    Set objDictionary = CreateObject(“scripting.dictionary”)
    ‘Select a source folder
    Set objFolder = Outlook.Application.Session.PickFolder

    deleted_count = 0
    processed_count = 0
    If Not (objFolder Is Nothing) Then
    UserForm1.Show (vbModeless)
    For i = objFolder.Items.Count To 1 Step -1
    Set objItem = objFolder.Items.Item(i)

    Select Case objFolder.DefaultItemType
    ‘Check email subject, body and sent time as well as sender
    Case olMailItem
    strKey = objItem.Subject & “||” & objItem.Body & “||” & objItem.SenderName & “||” & objItem.SentOn
    ‘Check appointment subject, start time, duration, location and body
    Case olAppointmentItem
    strKey = objItem.Subject & “,” & objItem.Start & “,” & objItem.Duration & “,” & objItem.Location & “,” & objItem.Body
    ‘Check contact full name and email address
    Case olContactItem
    strKey = objItem.FullName & “,” & objItem.Email1Address & “,” & objItem.Email2Address & “,” & objItem.Email3Address
    ‘Check task subject, start date, due date and body
    Case olTaskItem
    strKey = objItem.Subject & “,” & objItem.StartDate & “,” & objItem.DueDate & “,” & objItem.Body
    End Select

    strKey = Replace(strKey, “, “, Chr(32))

    ‘Remove the duplicate items
    If objDictionary.Exists(strKey) = True Then
    objItem.Delete
    deleted_count = deleted_count + 1
    Else
    objDictionary.Add strKey, True
    End If

    If (processed_count Mod 7) = 0 Then ‘don’t yield too much
    xx = DoEvents()
    End If

    processed_count = processed_count + 1

    UserForm1.Label1.Caption = “Processed ” & CStr(processed_count) & ” items (” & CStr(deleted_count) & ” duplicates)”
    Next i
    MsgBox (“Finished – processed ” & CStr(processed_count) & ” and deleted ” & CStr(deleted_count) & ” messages”)
    End If
    End Sub

  13. Peter,
    March 9, 2019 at 4:08 am

    My guess is that you might have emails that do not contain a “body”.

    But regardless, I would just put a “Try … End Try” around that code. If there are any issues with analyzing any email, then just don’t delete it.

    (To be clear, you’d put “Try … End Try” around the entire inside block for each iteration of “For i = objFolder.Items.Count To 1 Step -1”)

    Caveat: i don’t really know VBA

  14. Steve,
    March 17, 2019 at 10:10 pm

    You’re a genius! Worked perfectly for me.

  15. MNL,
    July 15, 2019 at 6:38 pm

    Worked wonderfully in Office 365 running on a Windows 10 machine. Bless you!

  16. TS,
    August 5, 2019 at 10:57 am

    I’m not very familiar with VBA or macros. I also get the “Run-time error ‘438’. Could anyone post a complete code with the code that worked.

  17. keenoar,
    September 8, 2019 at 9:43 pm

    Updated script for “Run-time error ‘438’: Object doesn’t support this property or method” (Line 19: replace objItem.SentOn with objItem.CreationTime):

    Sub RemoveDuplicateItems()
    Dim objFolder As Folder
    Dim objDictionary As Object
    Dim i As Long
    Dim objItem As Object
    Dim strKey As String

    Set objDictionary = CreateObject(“scripting.dictionary”)
    ‘Select a source folder
    Set objFolder = Outlook.Application.Session.PickFolder

    If Not (objFolder Is Nothing) Then
    For i = objFolder.Items.Count To 1 Step -1
    Set objItem = objFolder.Items.Item(i)

    Select Case objFolder.DefaultItemType
    ‘Check email subject, body and sent time
    Case olMailItem
    strKey = objItem.Subject & “,” & objItem.Body & “,” & objItem.CreationTime
    ‘Check appointment subject, start time, duration, location and body
    Case olAppointmentItem
    strKey = objItem.Subject & “,” & objItem.Start & “,” & objItem.Duration & “,” & objItem.Location & “,” & objItem.Body
    ‘Check contact full name and email address
    Case olContactItem
    strKey = objItem.FullName & “,” & objItem.Email1Address & “,” & objItem.Email2Address & “,” & objItem.Email3Address
    ‘Check task subject, start date, due date and body
    Case olTaskItem
    strKey = objItem.Subject & “,” & objItem.StartDate & “,” & objItem.DueDate & “,” & objItem.Body
    End Select

    strKey = Replace(strKey, “, “, Chr(32))

    ‘Remove the duplicate items
    If objDictionary.Exists(strKey) = True Then
    objItem.Delete
    Else
    objDictionary.Add strKey, True
    End If
    Next i
    End If
    End Sub

  18. Path11 Media,
    September 28, 2019 at 12:03 am

    I’m not getting any of this to work. Just reset Windows 10, everything new, accidently imported pst without killing dupes. This is Office 365 so it is creating OST files. The first set of code gets te 438 error, the second is just a mess.

  19. Yura,
    October 5, 2019 at 3:12 pm

    Just do that in original code: (Line 19: replace objItem.SentOn with objItem.CreationTime), works perfectly. Thanks a lot!

  20. Gal,
    November 10, 2019 at 5:38 pm

    Very Good It does what it promises!

  21. Kevin,
    December 27, 2019 at 3:08 pm

    Many, many thanks, exactly what I was looking for and it works perfectly once I’d sorted out the characters, as follows;

    For those struggling to get it to work;

    Back in the day I used to do a lot of VBA programming and like most amateurs I borrowed huge amounts of code from people who were kind enough to share it on the web, and one thing I learned was this. Sometimes when you copy and paste code from the web certain characters get pasted in a different format. I don’t know why, I imagine it’s something to do with html, but it’s usually characters like ” or , or ‘ rather than letters or numbers.

    If you re-type these characters one by one the code should run. Basically you should end up with blue & black text (the code) and green text (remarks, which are preceded by the ‘ symbol). alternatively you can preface each remark line with REM and it’ll do the same job. If you have any red text it means the prog can’t make any sense of that line (it’s probably a remark so add REM at the beginning of the line).
    Also, don’t be afraid to use ‘debug’ if it stalls. It’ll highlight the offending characters.

    By the way, in case you’re wondering whether this is some kind of sneaky virus or trojan, it’s not – that was the first thing I looked for! It’s also surprisingly quick to run – I’ve just cleaned up a 5Gb archive in a few minutes, where a server issue meant I’d created up to 5 duplicates making the files almost unmanageable.

  22. Warren,
    February 19, 2020 at 1:44 pm

    Does this routine permanently and irrevocably delete what it thinks to be duplicates or does it just move them to the deleted-items folder where they may be reviewed before being dumped (or restored)?

Leave a message: