Cookies help us deliver our services. By using our services, you agree to our use of cookies.
Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

How to merge two folders without duplicates into one folder in Outlook?

In Outlook, you may have many email accounts with many folders, in some cases, you want to merge two folders into one and remove the duplicate items. How can you quickly solve this job? In this article, I introduce a VBA code to help you handle it as quickly as possible in Outlook.

Merge two folders without duplicates into one by VBA code

Merge multiple folders and remove duplicate items with Kutools for Outlook

Consolidating multiple folders into one folder in outlook

In Outlook, there may be multiple folders, for easily consolidating, you may want to merge the same type folders to one, for example, merge all Inboxes across accounts into one. The Consolidating Folders of Kutools for Outlook works for this. Just need quick clicks, the selected folders will be combined into one .    Click for full future 45 days free trial!
doc consolidate and remove duplicate 1
 
Kutools for Outlook: with dozens of handy Outlook add-ins, free to try with no limitation in 45 days.
 
 
 
 

Merge two folders without duplicates into one by VBA code

To merge two folders into one and remove the duplicate items, you can handle it with VBA code as following steps:

1. Press Alt + F11 keys to enable the Microsoft Visual Basic for Applications window

2. Double click at ThisOutlookSession from Project1 in left pane, then copy and paste below code to the right script.

VBA: Merge two folders without diplicates

Sub MergeOutlookFolders_WithoutDuplicates()
'UpdatebyExtendoffice20180521
Dim xSourceFolder As Outlook.Folder
Dim xTargetFolder As Outlook.Folder
Dim xCount, i As Long
Dim xItem As Object
Dim xSourceItem As Object
Dim xTargetItem As Object
Dim xDictionary As Scripting.Dictionary  'Object
Dim xStr As String
On Error Resume Next
Set xDictionary = New Scripting.Dictionary
Set xSourceFolder = Application.Session.PickFolder
Set xTargetFolder = Application.Session.PickFolder
xCount = 0
If xSourceFolder.DefaultItemType <> xTargetFolder.DefaultItemType Then
    MsgBox "Error: The two folders are not in same type!", vbExclamation + vbOKOnly, "Kutools for Outlook"
    Exit Sub
End If
For i = xSourceFolder.Items.Count To 1 Step -1
    Set xSourceItem = xSourceFolder.Items.Item(i)
    xSourceItem.Move xTargetFolder
Next
For i = xTargetFolder.Items.Count To 1 Step -1
    Set xTargetItem = xTargetFolder.Items.Item(i)
    Select Case xTargetItem.Class
        Case olMail
            With xTargetItem
                xStr = .Subject & .Body & .SentOn
            End With
        Case olAppointment
            With xTargetItem
                xStr = .Subject & .Start & .Duration & .Location & .Body
            End With
        Case olContact
            With xTargetItem
                xStr = .FullName & .Email1Address & .Email2Address & .Email3Address
            End With
        Case olTask
            With xTargetItem
                xStr = .Subject & .StartDate & .DueDate & .Body
            End With
    End Select
    If xDictionary.Exists(xStr) = True Then
        xTargetItem.Delete
        xCount = xCount + 1
    Else
        xDictionary.Add xStr, True
    End If
Next i
If xCount <> 0 Then
    MsgBox xCount & " duplicates removed when merging!", vbInformation + vbOKOnly, "Kutools for Outlook"
End If
End Sub

doc merge folders without duplicates 1

3. Click Tools > References and in the popping dialog, check Microsoft Scripting Runtime checkbox.

doc merge folders without duplicates 2 doc arrow right doc merge folders without duplicates 3

4. Click OK. Now press F5 key to run the code. A dialog pops out to remind you select the first folder you want to merge (note: all the items in the first folder will be removed after merging with the second folder).
doc merge folders without duplicates 4

5. Click OK, in the second popping dialog, choose the second folder you want to compare and merge with.
doc merge folders without duplicates 5

6. Click OK, now, all the items in the first folder will be moved to the second folder, and the duplicate ones are also removed.
doc merge folders without duplicates 6


Merge multiple folders and remove duplicate items with Kutools for Outlook

If you are not familiar with VBA code, try to use Kutools for Outlook, a handy add-in, with its Consolidating Folders and Duplicate Emails utilities which can easily and quickly handle this job.

Kutools for Outlook , Includes 100+ powerful features and tools for Microsoft Outlook 2016, 2013, 2010 and Office 365.

Free install Kutools for Outlook, and then do as below steps:

Merge multiple folders

1. Click Kutools Plus > Consolidating Folders, then in the Merge multiple folders into one dialog, click Add to add the folders into list which will be merged, choose a folder as the destination folder.
doc consolidate and remove duplicate 1

2. Click OK > OK. Now all the items in the selected folders have been merged into one specific folder.
doc consolidate and remove duplicate 2

Remove duplicate items

3. Click Kutools > Delete Duplicate > Duplicate Emails. Then in the Duplicate messages dialog, check the folder you want to remove duplicates.
doc consolidate and remove duplicate 3

4. Click Next, in Duplicate Messages Settings dialog, specify the criteria you use to compare emails, then check Delete duplicate messages option and select Compare for duplicate messages within a single folder.
doc consolidate and remove duplicate 4

5. Click Next > Next, the duplicate emails have been filtered. Click Delete duplicate message button > OK to remove the duplicate emails successfully.
doc consolidate and remove duplicate 5 doc merge folders without duplicates 6



Kutools for Outlook

More than 100 Advanced Functions for Outlook 2010, 2013, 2016, 2019 and 365

screen shot kutools for outlook tiny for banner 201812

More Features  |  Free Download  |  Only $39.00 for hundreds of functions

Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.

Be the first to comment.