How to Quickly Create a Contact Group from the Recipient List of an Email with Outlook VBA

At times, when you send or receive an email with many recipients, you may want to create a contact group for these recipients. This article will introduce a quick way to accomplish it with Outlook VBA.

In our previous article “How to Create a Contact Group from Recipient List”, we have learned a common method to create the contact group for email recipients. That is to firstly select and copy the recipients from the emails, and then create a contact group manually and paste the recipients in “Members ->” field. Obviously, this means is extremely cumbersome. Therefore, here we will introduce another approach, which will utilize Outlook VBA to rapidly achieve a new contact group. You can just press a button without needs to repetitively copy and paste. Read on to get the elaborate steps and VBA codes.

Create a Contact Group from the Recipient List of an Email

  1. For a start, you should turn to “Developer” tab in Outlook.
  2. Then under this tab, you can locate and click on “Visual Basic” button.
  3. After that, a new “Microsoft Visual Basic for Applications” window will open. Now you should open a new module by clicking “Insert” > “Module”.Insert a New Module
  4. Next in the new module window, you can copy and paste the following codes into it.
Sub createcontactgroupforrecipients()
    Dim obApp As Application
    Dim olSel As Selection
    Dim obj As Object
    Dim oMail As MailItem
    Dim tempMail As MailItem
    Dim Recips As Recipients
    Dim ConGroup As DistListItem
    Dim strName As String
 
    Set obApp = Outlook.Application
    Set olSel = obApp.ActiveExplorer.Selection
 
    For Each obj In olSel
        If obj.Class = olMail Then
           Set oMail = obj
           Set tempMail = oMail.ReplyAll
           Set Recips = tempMail.Recipients
           Set ConGroup = obApp.CreateItem(olDistributionListItem)
           strName = InputBox("Specify a name for the new contact group:")
           With ConGroup
                .AddMembers Recips
                .DLName = strName
                'Use ".Save" to directly save the new contact group
                .Display
           End With
           tempMail.Close olDiscard
        End If
     Next
End Sub

Copy the VBA Codes into the New Module

  1. Later you can exit the current “Visual Basic” window and proceed to add the new macro to the Quick Access Toolbar. Click on the down arrow in the Quick Access Toolbar and choose “More Commands” from its drop down list.
  2. Subsequently, you will get into the “Outlook Options” window. At this point, you need to take the following steps:
  • Firstly, set “Choose commands from” to “Macros”.
  • Then seek out and pitch out the previously added macro.
  • Next click on “Add” button in center.
  • Lastly press “OK” button.Add the New Macro to Quick Access Toolbar
  1. After that, you can return to your Outlook mail pane and have a try.
  • At first, you can pitch on one mail in any mail folder.
  • Then click the button in the Quick Access Toolbar, like the image below:Select an Email and Click on the Button in Quick Access Toolbar
  • And next you will receive a message box, which demands you to specify a name for the new contact group.Specify a name for the new contact group
  • Later click “OK” button. At once, the new contact group, which contains all the selected email recipients, will open. You can hit “Save & Close” to save it.Save the Contact Group

Must-Haves in Outlook Data Protection

Due to the fact that Outlook is vulnerable, you should make sufficient precautions to safeguard their Outlook data. Firstly, you ought to make a regular Outlook data backup. In addition, you need to know how to find out and run the built-in repair tool, Scanpst.exe. The last but not least necessity is a stellar external corrupted Outlook data repair tool, such as DataNumen Outlook Repair, which will come to your rescue if backup and Scanpst.exe both fail.

Author Introduction:

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

One response to “How to Quickly Create a Contact Group from the Recipient List of an Email with Outlook VBA”

  1. I esteem the consideration on early area and its work in additional creating prosperity results. Helpful blog!

Leave a Reply

Your email address will not be published. Required fields are marked *