Mail Merge to Contact Groups

Last reviewed on April 28, 2014   —  No comments yet

In a thread in OutlookForums, a user wanted to know if it was possible to mail merge to Contact Groups, as groups; for example, create a mail merge to 20 Contact groups and send 20 messages, 1 to each group. This isn't possible using Outlook's Mail Merge function as doesn't let you use Contact Groups in a merge.

The macro creates individual messages

To merge individual messages to members of a Contact group, see Mail merge to members of a contact group

Although this code is designed to send individual messages to Contact Groups, it can be used with contacts, as any entry in the To field will be added to a message. It may be faster to use this macro to send messages instead of using the built-in Mail Merge function, provided you don't want to personalize the message using fields from the contacts.

Mail Merge Macro

To use this code, compose the message you wish to send and enter the Contact Groups (or Contacts) in the To field, and then run the macro. The macro creates a new message for each recipient and closes the "template" message.

Create a message and add the merge recipients to the To field

Sub MailMergeDL()
Dim objApp As Outlook.Application
Dim objItem As Outlook.MailItem
Dim objMsg As Outlook.MailItem
Dim objOutlookRecip As Recipient
Dim Recipients As Recipients

Dim i As Integer

Set objApp = Application
Set objItem = objApp.ActiveInspector.CurrentItem

If objItem.Recipients.Count > 0 Then
   
    For i = 1 To objItem.Recipients.Count
    
    Set objMsg = objApp.CreateItem(olMailItem)
    
    With objMsg
      .HTMLBody = objItem.HTMLBody
     .Subject = objItem.Subject
     .Recipients.Add objItem.Recipients(i)
    End With
    
    For Each objOutlookRecip In objMsg.Recipients
        objOutlookRecip.Resolve
    Next
    
    objMsg.Display
  
    Next i
  
End If
' close the merge template without saving
objItem.Close olDiscard 'use olSave to save a draft 

Set objItem = Nothing
Set objApp = Nothing

End Sub

Using the VBA Editor

First: You will need macro security set to low during testing.

To check your macro security in Outlook 2010 or 2013, go to File, Options, Trust Center and open Trust Center Settings, and change the Macro Settings. In Outlook 2007 and older, it’s at Tools, Macro Security.

After you test the macro and see that it works, you can either leave macro security set to low or sign the macro.

Open the VBA Editor by pressing Alt+F11 on your keyboard.

To use the macro code in ThisOutlookSession:

  1. Expand Project1 and double click on ThisOutlookSession.
  2. Copy then paste the macro into ThisOutlookSession. (Click within the code, Select All using Ctrl+A, Ctrl+C to copy, Ctrl+V to paste.)

More information as well as screenshots are at How to use the VBA Editor

Written by

Diane Poremsky
A Microsoft Outlook Most Valuable Professional (MVP) since 1999, Diane is the author of several books, including Outlook 2013 Absolute Beginners Book. She also created video training CDs and online training classes for Microsoft Outlook. You can find her helping people online in Outlook Forums as well as in the Microsoft Answers and TechNet forums.

Please post long or more complicated questions at Outlookforums.

Leave a Reply

If the Post Coment button disappears, press your Tab key.