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, below. Thank you!


Office Protected View How to remove/disable Protected View
An easy step-by-step guide how to disable the senseless Protected View feature of Microsoft Office under a minute!

Outlook Duplicate Remover How to Remove Duplicate Emails on Outlook
There is only one thing more annoying than duplicate emails: Outlook’s stupidity not to provide a feature that does! Here is the solution…

Service Error Message in Windows How to change Services Status Through Registry in Windows
Sometimes it’s not possible to change the services state of a service in Windows through the usual tool. Some may experience “The parameter is incorrent” and other error messages. This fast workaround shows how you can change that status anyway.

How to delete Outlook 365 Search History How to delete Outlook 365 Search History
It can’t be annoying if Outlook 365 keeps your search history and there is no way for you to delete it. This problem has been discussed in a lot of forums and so far nobody seems to find a solution. However, the solution is quite easy, it just needs a little trick. I will show you how to delete your history in 3 easy steps.

How to start Windows Defender How to Restart Windows Defender
Don’t tell me your Windows Defender won’t start – because no matter how hard you click on that button “Restart now” nothing happens. It’s totally ignoring you. But no worries. As it seems that we as users are smarter than Microsoft Developers. Because here is the simple trick how to solve it.

How to remove Outlook folders How to remove annoying Outlook Folders
Have ever used these useless folders such as “Journal”, “Tasks”, “Notes” and “RSS Feeds”? No you haven’t, you know why? Because nobody has. But Microsoft insists you see them every day, because there is no option to remove them. Here is a simple hack how to get rid of them for once and for all!

How to stop desktop icons from moving How to stop desktop icons from moving to another screen
Since the last Windows 10 update, Microsoft thinks it’s a great idea to randomly move your icons to another screen. When Windows does what it wants without asking, emotions usually run high. This could be the beginning of an artificial intelligence Windows – or more likely: Microsoft developers are just morons (tell me something I don’t know).

Photoshop too slow Photoshop Brush Lag / Slow: How to Solve the Error
Is your Photoshop brush lagging and is too slow? When the brush lags like this it causes you to drive zigzag lines. It can be helpful to write zigzag lines sometimes – but especially when you’re trying to draw a round line, a zigzag is not the best way to go, right? Here is a quick guide to solve your problem for once and for all.

Search Bar Windows Where is the Search Box in Windows 10?
Are your searching for the search? Has your Windows Search Box disappeared, too? Well, have you looked under the sofa? And didn’t find it there? Well, then this guide will help you how to get your search box back. Because it’s there… you’re just not looking at the right place.

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

Leave a message: