How to Batch Remove All Lost Members from Multiple Contact Groups in Your Outlook

When you click “Update Now” button in an open contact group, you may receive a message that some members cannot be found. And you will get an option to remove the lost members. If you want to remove all lost members in many contact groups, you can use the method introduced in this article.

After you open a contact group in Outlook, you can see an “Update Now” button. Not only can it go through all the members and update the relevant contact info, but also it will find out the lost members that cannot be found in Outlook. If you would like to remove such members, you can use the “Remove the lost members” option, as shown in the following figure.

Remove the lost members

It is easy and quick to process a single contact group. But, if you want to remove lost members from a lot of contact groups, you can use the following way. It will permit you to process multiple contact groups in one go.

Batch Remove All Lost Members from Contact Groups

  1. To begin with, access Outlook VBA editor via “Alt + F11”.
  2. Then, in the new screen, put the following VBA code into a module.
Sub BatchRemoveLostMembersFromAllContactGroups()
    Dim objContacts As Items
    Dim objItem As Object
    Dim objContactGroup As DistListItem
    Dim objGroupMember As Recipient
    Dim strFilter As String
    Dim i, n, x As Long
    Dim objFoundContact As ContactItem
    Dim strLostMemberList As String
 
    'Get all items in the default Contacts folder
    Set objContacts = Application.Session.GetDefaultFolder(olFolderContacts).Items
 
    For Each objItem In objContacts
        'Process all contact groups in this folder
        If TypeOf objItem Is DistListItem Then
           Set objContactGroup = objItem
 
           On Error Resume Next
           For i = 1 To objContactGroup.MemberCount
               Set objGroupMember = objContactGroup.GetMember(i)
 
               For x = 1 To 3
                   strFilter = "[Email" & x & "Address] = " & objGroupMember.Address
                   Set objFoundContact = objContacts.Find(strFilter)
                   If Not objFoundContact Is Nothing Then
                      Exit For
                   End If
               Next x
 
               'Get the list of lost members in the group
               If objFoundContact Is Nothing Then
                  strLostMemberList = objGroupMember.Address & ";" & strLostMemberList
               End If
           Next i
 
           'Remove the lost members from the group
           Call RemoveMembers(objContactGroup, strLostMemberList)
        End If
    Next
End Sub

Sub RemoveMembers(ByVal objGroup As DistListItem, ByRef strList As String)
    Dim varArray As Variant
    Dim y As Long
    Dim objTempMail As MailItem
    Dim objTempRecipient As Recipient
 
    objGroup.Body = objGroup.Body & vbCr & "Remove Lost Members: " & vbCr
 
    varArray = Split(strList, ";")
 
    For y = LBound(varArray) To UBound(varArray)
        Set objTempMail = Application.CreateItem(olMailItem)
        Set objTempRecipient = objTempMail.Recipients.Add(Name:=varArray(y))
        objTempRecipient.Resolve
        objGroup.RemoveMember Recipient:=objTempRecipient
        objGroup.Body = objGroup.Body & vbCr & varArray(y)
        objGroup.Save
    Next
End Sub

VBA Code - Batch Remove All Lost Members from Contact Groups

  1. After that, press “F5” key button to run this macro.
  2. When macro finishes, check the contact groups in the default Contacts folder. The lost members have been removed. And the removed members have been recorded in the Group “Notes” section.Lost Members Recorded in Contact Group Notes

Fix Compromised Outlook PST File

Maybe you have noticed that Outlook is prone to crash. At the best, in such cases, nothing bad will occur. Yet, at the worst, your Outlook PST file may be corrupt. At this point, you need to call in an experienced repair tool, like DataNumen Outlook Repair. It can recover Outlook data from the damaged file like a breeze.

Author Introduction:

Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including corrupted mdf and outlook repair software products. For more information visit www.datanumen.com

Comments are closed.