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

LIST OF TOP VPNs

Top Antivirus Tools 2024

Advertisement: Sponsored Listings
1 Norton Security Antivirus
Norton Security Antivirus
Review Rating 5.0
from $34.99
Norton Antivirus is one of our review winners in 2024. 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 $34.99
In 2024 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 $34.68
One of the advantages of Avast 2024 is not just it's reliability and broad antivirus protection but also the price. At only $34.68, it's one of the most affordable deals you can find among reputable antivirus tools.
4 Panda Security
Panda Security
Review Rating 4.7
from $28.79
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.
5 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.
6 McAfee Antivirus
McAfee Antivirus
Review Rating 4.4
from $34.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 2024.
7 Avira Antivirus Pro
Avira Antivirus Pro
Review Rating 1
Price not available
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 $0.99, they make switching to the professional version worth it. However, support is not Avira's forte.

Recent Articles About Software SHOW ALL ARTICLES

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

  1. joel,
    May 15, 2023 at 8:45 pm

    Hi, also getting runtime 438 error.
    this line is highlighted when i click debug
    strKey = objItem.Subject & “,” & objItem.Body & “,” & objItem.SentOn

  2. June 14, 2021 at 1:04 pm

    Great tool! Worked like a charm in the Office 365 Outlook (pst file)! I would like to publish your script on my blog (with mentioning the source), because this piece of gold should be as public as it can be!

  3. John,
    February 7, 2021 at 1:53 am

    Fantastic — thank you!

    Can I do something similar to strip attachments from IMAP e-mails?

  4. Jody Roody,
    February 3, 2021 at 6:37 pm

    It seems that others are getting resulting a confirmation of emails, calendars, and contacts removed. I receive no confirmation. Cannot determine what I am doing in erroror or does it not actually provide the result?
    Thank you

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

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

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

    Fantastic.

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

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

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

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

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

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

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

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

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

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

    Very Good It does what it promises!

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

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

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

Leave a Reply

Your email address will not be published. Required fields are marked *

* Please select reCAPTCHA