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 2021
Top VPN Tools 2021: Tested & Reviewed Don't Let Them Spy on Your Data!

LIST OF TOP VPNs

Top Antivirus Tools 2021

Advertisement: Sponsored Listings
1 Norton Security Antivirus
Norton Security Antivirus
Review Rating 5.0
from $39.99
Norton Antivirus is one of our review winners in 2021. 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
AVG Internet Security
Review Rating 5.0
from $49.99
In 2021 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
Avast Pro Antivirus
Review Rating 4.9
from $55.99
One of the advantages of Avast 2021 is not just it's reliability and broad antivirus protection but also the price. At only $55.99, it's one of the most affordable deals you can find among reputable antivirus tools.
4 Bullguard Antivirus
Bullguard Antivirus
Review Rating 4.7
from $19.49
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
Panda Security
Review Rating 4.7
from $35.39
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
Kaspersky Antivirus
Review Rating 4.7
from $29.99
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, Kaspersky Anti-Virus, Kaspersky Internet Security and more.
7 McAfee Antivirus
McAfee Antivirus
Review Rating 4.4
from $29.99
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 2021.
8 Avira Antivirus Pro
Avira Antivirus Pro
Review Rating 3.0
from $57.99
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 $57.99, they make switching to the professional version worth it. However, support is not Avira's forte.

Recent Articles About Software SHOW ALL ARTICLES

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

  1. Todd,
    January 10, 2021 at 11:14 pm

    It doesn’t work. Nothing happens (Outlook 365, Windows 10) when I run the script. No duplicates are removed. Any suggestions?

  2. Robert Ryanson,
    January 9, 2021 at 1:10 pm

    Amazing. So simple and it worked perfectly. Thank you for sharing this! This is what the Internet is all about. Vielen Dank.

  3. John,
    November 27, 2020 at 9:22 pm

    Fantastic.

  4. Tsuby,
    November 8, 2020 at 3:17 pm

    Perfect. Just what I needed. THANK YOU! It worked flawlessly and I could delete over 2500 duplicate messages (due to Outlook not importing the old Gmail tags…).
    I could finally declutter my inbox easily and without spending money for “tools” that could not even find any duplicates. You saved my day.

  5. Albert,
    October 21, 2020 at 12:49 am

    Thank you for posting this. I benefited from it and was able to get rid of duplicated mails. You saved me a lot of time and headache!

  6. Mark H,
    September 7, 2020 at 10:29 pm

    Great stuff!
    Works as promised and quickly.
    Thanks very much for sharing the clean, simple code.

  7. Minime,
    September 3, 2020 at 10:18 am

    You are my hero!!!! thanks for the code. It saved my life.
    Works like a dream

  8. Ankit,
    August 29, 2020 at 6:47 pm

    Hi guys,

    I’m late to discussion. The error 438 was resolved and the script worked perfectly for small folder. But when I chose my main folder (over 30GB) , i get runtime error ‘430’: Class does not support automation or does not support expected interface.

    Can someone please help ? Im very new to macros.

  9. Lorraine,
    July 5, 2020 at 6:39 am

    Thank you for this script. I’ve been moving to a new computer and decided to go IMAP instead of POP. I accidentally imported one PST into the wrong account. I figured, no problem, I’ll just delete the accounts and re-do it. Well, I ended up with duplicates. Then tried the export/import without duplicates and ended up with triplicates or quadruplicates. All synced to my webhost. Looked into the tools, but when the grammar isn’t correct, I get uneasy. Then I saw this. Had a coder friend give it the once-over and then followed your very clear instructions and cleaned up my 3-year-old stash of emails. Well, “clean” may be debatable. But it is definitely de-duped. Thank you!

  10. 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)?

  11. 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.

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

    Very Good It does what it promises!

  13. 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!

  14. 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.

  15. 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

  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. MNL,
    July 15, 2019 at 6:38 pm

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

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

    You’re a genius! Worked perfectly for me.

  19. 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

  20. 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

  21. 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

  22. 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?

  23. 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

  24. 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?

  25. 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”

  26. 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 ^^^ :'(

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

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

  28. 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.

  29. 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

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

    That’s brilliant. Works a treat. Thanks

  31. 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.

Leave a message: