How to Batch Expand All Contact Groups in “To” Field when Composing an Outlook Email

Many users long for a method, which can enable them to expand all contact groups in “To” field in bulk when composing an Outlook email. Therefore, in this post, we’ll share you such an approach.

Usually, to expand a contact group in “To” field, you can click the “+” icon in front of the group name. However, by this means, if there are many contact groups in “To” field and if you want to expand all of them, it is a bit tedious. Thus, here we’ll share you a way to quickly expand all groups in “To” field simply via a click.

Batch Expand All Contact Groups in "To" Field when Composing an Outlook Email

Batch Expand All Contact Groups in “To” Field

  1. In the first place, launch your Outlook program.
  2. Then in the main Outlook window, press “Alt + F11” key buttons.
  3. Next you will get into the VBA editor screen, in which you ought to access an unused module or simply insert a new one.
  4. Subsequently, copy the following VBA code into this module.
Sub ExpandAllContactGroupsInToField()
    Dim objMail As Outlook.MailItem
    Dim objRecipients As Outlook.Recipients
    Dim bContactGroupFound As Boolean
    Dim i As Long
 
    'Get the current mail
    Set objMail = ActiveInspector.CurrentItem
    bContactGroupFound = True
 
    Do While bContactGroupFound = True
       Set objRecipients = objMail.Recipients
       bContactGroupFound = False
 
       'Expand all contact groups in "To" field
       For i = objRecipients.Count To 1 Step -1
           If objRecipients(i).Type = olTo Then
              If objRecipients(i).AddressEntry.DisplayType <> olUser Then
                 For n = 1 To objRecipients(i).AddressEntry.Members.Count
                     If objRecipients(i).AddressEntry.Members.Item(n).DisplayType = olUser Then
                        objMail.Recipients.Add (objRecipients(i).AddressEntry.Members.Item(n).Address)
                     Else
                        objMail.Recipients.Add (objRecipients(i).AddressEntry.Members.Item(n).Name)
                        bContactGroupFound = True
                     End If
                 Next
                 objRecipients(i).Delete
              End If
          End If
      Next i
      objRecipients.ResolveAll
    Loop
End Sub

VBA Code - Batch Expand All Contact Groups in "To" Field

  1. After that, you can exit the current window just by clicking the cross icon in the upper right corner.
  2. Later you need to add this VBA project to the Quick Access Toolbar of Message window.
  • First off, create a new mail.
  • Then click on the down arrow in the upper left corner.
  • Next choose “More Commands”.
  • In the new dialog box, you can take the steps shown in the image below to complete adding macro to Quick Access Toolbar.Add this VBA project to the Quick Access Toolbar of Message window
  1. Finally, you can take a shot:
  • To start with, create and compose a new email as normal.
  • Then add several contact groups in the “To” field.
  • After that, you can click the macro button in Quick Access Toolbar.Run the Macro
  • At once, all the contact groups will be expanded, like the following image:Expanded Contact Groups

Rescue Your Outlook Data Timely

Generally, as soon as confronted with any problems in your Outlook, inbox repair tool will occur to your mind in the first place. However, more often than not, it’ll not make any effects. At such times, it is recommended to recur to a more potent and trustworthy utility, such as DataNumen Outlook Repair. It can fix PST file in an instant, irrespective of how extremely your PST file is damaged.

Author Introduction:

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

3 responses to “How to Batch Expand All Contact Groups in “To” Field when Composing an Outlook Email”

  1. How about instead folks honor the purpose of email groups and not expand them? Why do you make it easier for folks ignorant of the purposes to defeat the work we’ve done to organize help the world with a single lazy click?

  2. Get an error with this Macros
    “Object variable or With block variable not set”

    highlights line below:
    For n = 1 To objRecipients(i).AddressEntry.Members.Count

Leave a Reply

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