best duplicate contact remover?

Status
Not open for further replies.

mr_malkovich

Senior Member
Outlook version
Outlook 2007
Email Account
Exchange Server
Hey all. I have Outlook 2013/Office 365 on Windows 7. I need a good application to delete contact files with containing duplicate email addresses across multiple Outlook contact folders. The only criteria I have for deleting a contact is if the email in Email Field 1 is the same. Not duplicate names or companies or anything else. I want the newer contact file to be deleted. I'd like it to be a one-touch process, ie: if 300 duplicate contacts are found, I want to be able to delete them with one touch. I was using Contact Scrubber but it doesn't work with 64-bit Outlook installations, and you have to delete each duplicate contact one by one.

Is there an app for this? Or should I look around for someone to write me something custom?

Thanks much.
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
I'm not sure of any of the duplicate removers are that specific - I know mapilab's can check the fields you specify. But... if email address is the only criteria and you want to always keep the newest, VBA should work fine, although it might be slower than a compiled app. Basically, search for the email address and if matches are found, delete the ones with older created date.
 

mr_malkovich

Senior Member
Outlook version
Outlook 2007
Email Account
Exchange Server
For instance, I have several hundred contacts in one Outlook contact sub-folder and a couple thousand in another. I need some kind of application or script that will find any contact folders across those folders containing duplicate email addresses, and delete the newer of the two.
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Do you need multiple folders? If not, it will be easier - you can drag everything to the main folder and if check for duplicates is enabled, you can merge the dupes.

This will delete the duplicates with matching emails. It doesn't check for creationtime, i tried to add an if statement to compare times but it only deletes 1 match when i use it. I'm obviously not doing something right - probably because this macro deletes the current contact, where I'm trying to compare it to the next one.

It also only works on the default contacts folder - its easy to make it work on any folder, but harder to make it check multiple folders.

Code:
Sub DeleteDuplicateContacts() 
  Dim contactItems As Outlook.Items 
  Dim contact As Outlook.ContactItem 
  Dim contactEmail As String 
  Dim filteredContacts As Outlook.Items 
  Dim countContacts As Long 
  Dim i As Long 
  Set contactItems = Session.GetDefaultFolder(olFolderContacts).Items 
  countContacts = contactItems.Count 
  For i = countContacts To 1 Step -1 
  
   If TypeName(contactItems.Item(i)) = "ContactItem" Then 
      Set contact = contactItems.Item(i) 
      contactEmail = contact.Email1Address 
If contactEmail = "" Then GoTo nexti 
      Set filteredContacts = _ 
    contactItems.Restrict("[Email1Address] = '" & contactEmail & "'") 
      If Not filteredContacts.Count = 1 Then ' possible dupe 
          contact.Delete 
      End If 
    End If 
nexti: 
  Next i 
End Sub
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Ah, figured it out, i think. This code checks the created time and deletes the newer contact.

Code:
Sub DeleteDuplicateContacts() 
  Dim contactItems As Outlook.Items 
  Dim contact As Outlook.ContactItem 
  Dim contactEmail As String 
  Dim filteredContacts As Outlook.Items 
  Dim countContacts As Long 
  Dim i As Long 
  Dim d As Long 
  Set contactItems = Session.GetDefaultFolder(olFolderContacts).Items 
  countContacts = contactItems.Count 
  For i = countContacts To 1 Step -1 
  
   If TypeName(contactItems.Item(i)) = "ContactItem" Then 
      Set contact = contactItems.Item(i) 
      contactEmail = contact.Email1Address 
Debug.Print contactEmail 
If contactEmail = "" Then GoTo nexti 
      Set filteredContacts = _ 
    contactItems.Restrict("[Email1Address] = '" & contactEmail & "'") 
      If Not filteredContacts.Count = 1 Then ' possible dupe 
       For d = filteredContacts.Count To 1 Step -1 
       Debug.Print d 
       On Error Resume Next 
      If contact.CreationTime > filteredContacts.Item(d).CreationTime Then 
          contact.Delete 
          Else 
          filteredContacts.Item(d).Delete 
        
     End If 
    
      Next d 
    End If 
  End If 
nexti: 
  Next i 
End Sub
 

mr_malkovich

Senior Member
Outlook version
Outlook 2007
Email Account
Exchange Server
Hmmm, yeah the application that will work for me is probably going to have to work across multiple folders. I still want to try this code though. How do I actually run it? Forgive me, I know I should know this. Also, my contact files are a custom form I've created - 112607.fdm. Will that affect the code?

Thank you so much. This week has been one obstacle after another since installing O365 but I know (hope?) it's for the best in the long term.
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
It *should* work with the custom form since it looks at the item type, not the form name, but if you only have contacts - no contact groups (DLs) - you can remove this line and the corresponding End if - the only purpose it serves is to avoid errors when there are contact groups.
If TypeName(contactItems.Item(i)) = "ContactItem" Then

To use it, paste it into the VB Editor and click Run.
http://www.slipstick.com/developer/how-to-use-outlooks-vba-editor/

The debug.print lines were used for error checking, they can be deleted.

When I get a chance I'll work on making it work across multiple folders.
 
Status
Not open for further replies.
Thread starter Similar threads Forum Replies Date
J What is the best EntryID format to set on MS Access table Outlook VBA and Custom Forms 3
B What is best IMAP .OST file to .PST file converter solutions? Using Outlook 1
P Best configuration for Outlook 2016, Gmail and iCloud Using Outlook 8
P Outlook room resource calendars and best practices Exchange Server Administration 0
Rupert Dragwater What is the best way to back up pst Using Outlook 4
Diane Poremsky The Best Outlook Store Add-ins Contest New Slipstick.com Articles 0
Patrick van Berkel Best way to share (and keep up-to-date) Macro's in Outlook 2010 Outlook VBA and Custom Forms 6
oliv- Best practice for catching mailitem.events Outlook VBA and Custom Forms 0
M What is the best way to find all records of an e-mail for our company? Outlook VBA and Custom Forms 2
J Best approach for restarting custom task form development after seemingly corrupt form environment Outlook VBA and Custom Forms 0
X Best utility for repairing PST files? Using Outlook 3
S Best method to use Outlook Standalone with iPhone New Slipstick.com Articles 13
D a suggestion ...sent with the best intentions Using Outlook 1
B What is the best way to use Outlook address book to select customer and then open Excel Outlook VBA and Custom Forms 22
M How best to track OUTGOING referrals? BCM (Business Contact Manager) 2
jobudge Reinstalled Outlook 2013 after system crash what is best way to synch with gmail? Using Outlook 1
M Best way to identify/designate contacts in incoming emails? Using Outlook 4
P Best way to locally backup/archive Gmail? Using Outlook 1
M Looking for options and best practices for an Edge Server (Exchange or not) Exchange Server Administration 0
O What are best practices for a re-install Office 13 w/BCM with OS re-install BCM (Business Contact Manager) 1
G what is the best way to organize outlook contacts Using Outlook 1
D What would be the best strategy? Using Outlook 3
crazyboy BCM Installation Best Practices? BCM (Business Contact Manager) 5
J Best way to move form old to new, larger pst? Using Outlook 2
M Best way to move outlook? Using Outlook 1
R Best way to share outlook calendar with 10 laptops Using Outlook 9
S Exchange 2010 CAS/HT/Mailbox moved - best practice/steps for decommissioning 2007 Exchange Server Administration 3
Horsepower Email best practice Using Outlook 3
N Outlook 2010, Categories, best way to filter contacts? Using Outlook 5
R Multiple CAS - Best practice with certificate request Exchange Server Administration 4
F Best Non MS Exchange 2010 book for beginners? Exchange Server Administration 7
S CAS/MBX reboot best practices. Exchange Server Administration 7
I Best Practice for Large Messages NDRs? Exchange Server Administration 4
L best rule/macro to send emails from many people/orgs to same folder Using Outlook 3
R Any "Best Practices" for a test/developer Exchange 2010 server? Exchange Server Administration 2
C Best way to effectively back up Outlook Calendar (and save Categories) and Email as well???? Using Outlook 6
K Edge transport and TMG best practice NLB Exchange Server Administration 1
R Best practices for creating "Equipment" mailbox resources? Using Outlook 1
D Exchange Best Practice for DEV/TEST/PROD Exchange Server Administration 2
M Exchange 2010: What to monitor - best practices Exchange Server Administration 4
K Best case scenerio to reduce disk space usage Exchange Server Administration 5
B Best way to get a pick-list on a form? Outlook VBA and Custom Forms 1
M Best way to distribute VBA project Outlook VBA and Custom Forms 4
E Where is the best place to store values for combobox entries Outlook VBA and Custom Forms 5
E Where is the best place to store values for combobox entries Outlook VBA and Custom Forms 5
T Is Explorer.FolderSwitch the best event for hiding commandbarbutton? Outlook VBA and Custom Forms 5
M Outlook 2007 / Vista / Windows XP best combo needed BCM (Business Contact Manager) 2
C Form Region, Task Pain, Ribbon Extension - which way is best? Outlook VBA and Custom Forms 1
O Delete duplicate emails - subscription notifications Using Outlook 5
T Deleting duplicate emails Using Outlook 2
Similar threads


















































Top