Sometimes, you may want to delete a specific contact from all the contact groups in your Outlook. In this case, searching and deleting one by one is quite cumbersome. So this article will teach you how to quickly accomplish it using VBA.
For some reasons, such as one colleague has resigned from your company, you’ll need to remove him from all the contact groups in your Outlook. Otherwise, next time when you send an email to the contact group, he will be likely to receive the email too. It will be quite embarrassing.
In this situation, if you have many contact groups, finding out the specific contact and removing it one by one is certainly troublesome. Therefore, here we will tell you another method, which can use Outlook VBA to help you remove the specific contact from all your contact groups simply via one click. Now read on to get the detailed steps and codes.
Remove a Specific Contact from All Contact Groups
- In the first place, start your Outlook application.
- Then switch to “Developer” tab and hit “Visual Basic” button. If you can’t find such a tab, you should go to “Options” > “Customize Ribbon” to enable it first.
- Next in the subsequent VBA editor window, you should open a module which is not in use.
- Subsequently, copy and paste the following VBA codes into it.
Sub RemoveSpecificContactfromAllGroups() Dim strSpecificContact As String Dim objTempMail As Outlook.MailItem Dim objRecipient As Outlook.recipient Dim objContactsFolder As Outlook.Folder Dim objItem As Object Dim objContactGroup As Outlook.DistListItem Dim objContact As Outlook.ContactItem Dim nprompt As Integer strSpecificContact = InputBox("Input the fullname or email address of the specific contact to be removed from all contact groups:") Set objTempMail = Outlook.Application.CreateItem(olMailItem) Set objRecipient = objTempMail.Recipients.Add(strSpecificContact) objRecipient.Resolve If objRecipient.Resolved = True Then Set objContactsFolder = Outlook.Application.Session.GetDefaultFolder(olFolderContacts) For Each objItem In objContactsFolder.Items If TypeOf objItem Is DistListItem Then Set objContactGroup = objItem With objContactGroup .RemoveMember objRecipient .Body = "Contact Removed: " & strSpecificContact & vbTab & "(" & Now & ")" & .Body .Save End With End If Next nprompt = MsgBox("Removing Completes!", vbExclamation, "Remove Contact from Group") Else nprompt = MsgBox("This contact cannot be resolved!", vbExclamation, "Resolving Error") End If End Sub
- After that, click the “run” icon in the toolbar.
- Later you will be required to input the name or email address of the specific contact to be removed from all groups.
- Immediately, Outlook will resolve this contact, if resolved successfully, it’ll be removed from all groups. And you will get a prompt, like the image below:
- Now you can open a contact group to check. Moreover, in the contact group’s Notes field, you can see a note, like the following image:
Avoid Frustrating Outlook Data Loss
You may have a great deal of important data in your Outlook PST file, such as the client information, etc. Thus, in the event of unexpected corrupted Outlook PST file, you will try your best to recover it. Under this circumstance, you have to use a much more powerful tool than Scanpst.exe, such as DataNumen Outlook Repair.
Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including sql fix and outlook repair software products. For more information visit www.datanumen.com