હિમાંશુ પરભુભાઇ મિસ્ત્રી | Himanshu Mistry

January 4, 2008

MACRO for Finding Duplicate contacts in MS Outlook

Filed under: Uncategorized — Himanshubhai Mistry @ 3:13 pm
Tags: , , ,

Below is the code for flaging duplicate contact cards in MSOutlook 

you have to copy paste in VB Editor of outlook (press alt + F11) and then run the function

Public Sub deleteduplicatecontacts()
Dim oldcontact As ContactItem, newcontact As ContactItem, j As Integer
Set mynamespace = GetNamespace(“MAPI”)
Set myfolder = mynamespace.GetDefaultFolder(olFolderContacts)
Set myitems = myfolder.Items
myitems.Sort “[File As]”, olDescending
totalcount = myitems.Count
j = 1
While ((j < totalcount) And (myitems(j).Class <> olContact))
  j = j + 1
Wend
Set oldcontact = myitems(j)
For i = j + 1 To totalcount
  If (myitems(i).Class = olContact) Then
  Set newcontact = myitems(i)
  ‘if((newcontact.lastmodificationtime = oldcontact.lastmodificationtime) and
  If ((newcontact.LastNameAndFirstName = oldcontact.LastNameAndFirstName) And _
  (newcontact.FileAs = oldcontact.FileAs) And _
  (newcontact.PagerNumber = oldcontact.PagerNumber) And _
  (newcontact.HomeTelephoneNumber = oldcontact.HomeTelephoneNumber) And _
  (newcontact.BusinessTelephoneNumber = oldcontact.BusinessTelephoneNumber) And _
  (newcontact.BusinessAddress = oldcontact.BusinessAddress) And _
  (newcontact.Email1Address = oldcontact.Email1Address) And _
  (newcontact.HomeAddress = oldcontact.HomeAddress) And _
  (newcontact.CompanyName = oldcontact.CompanyName)) Then
  ‘use FTPSite as a flag to mark duplicates
  newcontact.FTPSite = “DELETEMESEYMOUR”
  newcontact.Save
  End If
  Set oldcontact = newcontact

End If
Next i
End Sub

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: