question

TalhaAhmed-8531 avatar image
0 Votes"
TalhaAhmed-8531 asked senorwillburr-9828 published

Duplicate emails in outlook

Hi

we have office 365 tenant, who got a user having duplicate emails in one of his inbox folder. We tried using builtin cleanup tools in outlook but seems like the tool is not reading emails as duplicated. is there any other way or script we can use to clean a folder in inbox?

thanks,

office-outlook-itpro
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @TalhaAhmed-8531,

Has your problem been solved? If so, please remember to mark the helpful reply as an answer so that people with similar questions can get reference.

0 Votes 0 ·
michev avatar image
1 Vote"
michev answered

First of all, open the mailbox in OWA, just to make sure that you're not seeing some local Outlook issue. As for automated solution to this, try this script: https://eightwone.com/2013/06/21/removing-duplicate-items-from-a-mailbox/

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

JadeLiang-MSFT avatar image
1 Vote"
JadeLiang-MSFT answered senorwillburr-9828 published

Hi @TalhaAhmed-8531,

Did the user import any .pst file to your mailbox before? As I know, it may cause some duplicate emails if we import a file and forget to choose "don't import duplicate". And agree with michev, we could first try to log into your web mail to check if there are any duplicate items there.

Also, for your requirement of removing duplicate in Outlook, I found a relevant VBA script below. Accoridng to my tests, it could remove the duplicate items that I copy and paste manually in a specific folder, so please try to press "Alt + F11" to paste the script and run it in the user's Outlook to check if it could also work for you (Notice: we may need to Enable all macro in Outlook to run the script--File>Option>Trust center>Trust center settings>Macro settings>Enable all macro) :

 Sub DeleteDuplicateEmailsInSelectedFolder()
    
 Dim i As Long
 Dim n As Long
 Dim Message As String
 Dim Items As Object
 Dim AppOL As Object
 Dim NS As Object
 Dim Folder As Object
    
 Set Items = CreateObject("Scripting.Dictionary")
    
 'Initialize and instance of Outlook
 Set AppOL = CreateObject("Outlook.Application")
    
 'Get the MAPI Name Space
 Set NS = AppOL.GetNamespace("MAPI")
    
 'Allow the user to select a folder in Outlook
 Set Folder = NS.PickFolder
    
 'Get the count of the number of emails in the folder
 n = Folder.Items.Count
    
 'Check each email starting from the last and working backwards to 1
 'Loop backwards to ensure that the deleting of the emails does not interfere with subsequent items in the loop
 For i = n To 1 Step -1
    
     On Error Resume Next
     'Load the matching criteria to a variable
     'This is setup to use the Sunject and Body, additional criteria could be added if desired
     Message = Folder.Items(i).Subject & "|" & Folder.Items(i).Body
    
         'Check a dictionary variable for a match
         If Items.Exists(Message) = True Then
         'If the item has previously been added then delete this duplicate
         Folder.Items(i).Delete
     Else
         'In the item has not been added then add it now so subsequent matches will be deleted
         Items.Add Message, True
 End If
    
 Next i
    
 ExitSub:
    
 'Release the object variables from memory
 Set Folder = Nothing
 Set NS = Nothing
 Set AppOL = Nothing
    
 End Sub


Hope that would be helpful to you.


If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



· 6
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @TalhaAhmed-8531,

Have you tried the script above? And does your issue have any update? If you still need further assistance, please feel to post back.

1 Vote 1 ·

HI
thanks for sharing script, the user was on Vac and he just came back so I am going to try it.

We have a one folder under inbox where the duplicates are present. Will this script allow me to choose that single folder?

The duplicates happened due to some outlook rule issue.

0 Votes 0 ·

Yes, according to my tests, we could choose any folder for your need, hope that could also be helpful to you.

0 Votes 0 ·

Hi @TalhaAhmed-8531,

Has your issue been solved after so long?
If not, please provide me with more information about your issue for further analysis.Thanks!

0 Votes 0 ·

Tried on one folder. It works
Thanks a ton

0 Votes 0 ·

JadeLiang-MSFT,
I am a novice at this. Would you take me step by step on how to run the script on my Outlook 365?
Thanks!
Will

0 Votes 0 ·