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.
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.
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:
- Expand Project1 and double click on ThisOutlookSession.
- 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
Very useful your articles, thank you for sharing with us.
I'd like to ask you something additionally.
Beside sending the message to several groups, I need to send them also an personalized excel report for each country.
Is it possible once you run the mail merge macro to add also the right report for each country to the right contact group ?
My report is at EMEA Level and it would be huge to send it to all of the groups at once.
Thank you in advance,
Yes, you could do that. You just need to figure out how you want to do it... the easiest might be based on a keyword in the group name (or the full group name) using a case statement, then add it using attachments.add.