Script to Remove Duplicate Emails in Outlook
User Query – Hello, Last night I was encountered by data corruption in my Outlook while moving data items from an online archive into a PST file. The good news is that I was able to recover my PST file data but many of the items get duplicated. Now, I know the manual method to remove duplicate emails. But I am looking for an instant way like VBA script or macros to remove duplicate emails in Outlook. So anybody knows the solution, then please help me.
Well, duplicate emails in Outlook are a very common issue faced by lots of Outlook users. But the consequences due to duplicate emails are more painful. Hence, users want an instant solution to get rid of it, and start searching for the VBScript or macros to remove duplicate emails in Outlook because these scripts give you an option to remove duplicates emails in bulk.
So stay with us because here in this article we are going to discuss script to remove duplicate emails in Outlook. But before starting the blog let see what are the reasons for duplicate emails in Outlook.
Why Duplicate Emails Occurs in Outlook
- Outlook rules are one of the major reasons behind duplicate emails because improper rules download the same emails again and again. This, in turn, users end with a huge number of duplicate emails in Outlook IMAP/POP mailbox.
- If users have set a short interval of inbox update time, then the mailbox component cannot synchronize properly and create duplicate emails in the inbox
- Using the same email multiple times on multiple devices is the reason for repeated synchronization of incoming data which leads to duplicate emails in Outlook.
- Sometimes due to a bad internet connection, the mail server of Outlook fails to respond while Sending/Receiving emails in Outlook. Moreover, the next sync will download the previous emails again
How to Write Script to Remove Duplicate Emails in Outlook?
Here in this section, we are talking about the VBScripts which is written in VB Editor. Basically, VBA stands for Visual Basic for Application it is used to create macros that can perform complex and complicated tasks in Outlook automatically. But Remember this task is contains programming so follow all the steps carefully.
1. First, open the Outlook program and press Alt+F11 to open the VB editor
2. In the VBA editor window, double click to open a module that is in use or directly insert a new module by “Insert” > “Module”
3. Now, copy and paste the below VBA codes into the module
Public Sub MoveDuplicates()
Dim objOL As Outlook.Application
Dim objFolder As Outlook.MAPIFolder
Dim objDupFolder As Outlook.MAPIFolder
Dim objDictionary As Object
Dim i As Long
Dim objItem As Object
Dim strKey As StringSet objOL = Outlook.Application
Set objDictionary = CreateObject(“scripting.dictionary”)
Set objFolder = objOL.ActiveExplorer.currentFolderOn Error Resume Next
Set objDupFolder = objFolder.Folders.Item(“Duplicates”)
If objDupFolder Is Nothing Then
Set objDupFolder = objFolder.Folders.Add(“Duplicates”)
End IfFor i = objFolder.Items.count To 1 Step -1
Set objItem = objFolder.Items.Item(i)
‘Only check email items type
If InStr(1, objItem.MessageClass) <> “IPM.Schedule” ThenstrKey = objItem.Subject & “,” & objItem.Body & “,” & objItem.SentOn
strKey = Replace(strKey, “, “, Chr(32))
If objDictionary.Exists(strKey) = True Then
objItem.Move objDupFolder
‘ use this to delete immediately
‘ objItem.Delete
Else
objDictionary.Add strKey, True
End If
End IfNext i
End Sub
4. Once the code is pasted, sign this macro and change your Outlook macro security level to low
5. Now, run this new VBA project by clicking on the “Run” icon in the top toolbar
6. Select the folder to move the duplicate emails.
7. Finally, after a few minutes, all the duplicate emails are deleted at once
One-Click Solution to Remove Duplicate Emails in Outlook
Well, as we see the above script method is totally technical. So there is very little chance that any non-technical users can able to complete this task. Also, it tasks time to run when you have a lot of duplicate emails in Outlook. However, we know that Outlook is susceptible to download duplicate emails, thus in that scenario users have to spend more effort to save their Outlook data.
Hence, in this troublesome situation, we can try Best Duplicate Remover Tool for Outlook. This the tool that does the same task in just a few clicks, also capable to remove duplicate emails from PST, OST and BAK files. While using this software you do not need to worry about data loss as well as the software gives you an option to remove duplicate from Outlook contacts, calendars, tasks, notes, and journals
Let’s see the five simple steps of the software to remove duplicate emails in Outlook
1. Download and install the software from the above download button
2. Now, click on the Add File(s) or Add Folder to add Outlook files
3. Select the Destination location to save the duplicate free Outlook file
4. Now, Choose Mail option from Select Item Type
5. Once all the settings are done, click on the Next button to complete the task
Conclusion
There are many users asking for the script to remove duplicate emails in Outlook on various forums. Hence, after considering all the queries we have come up with this write-up where we have discussed the method to delete duplicate emails in Outlook via VBA.