mail merging contacts and contact groups. can code achieve this?

Status
Not open for further replies.

mr_malkovich

Senior Member
Outlook version
Email Account
Exchange Server
Hey all. Got Outlook 2013/O365 on Windows 7.

I use Mail Merge all day, everyday. I also have plenty of contact groups. I would love to figure out a way to get Mail Merge to merge contacts AND contact groups in one merge, so that invididual contacts would continue to receive individual emails as usual, but the members of each selected contact group would receive group emails.

Is this remotely possible or am I wishing on a star here?
 
Hey there, thanks for this. This looks good except I also use a macro to insert each contact's name into the respective recipient's email title. How can I achieve this while using the contact group mail merge macro?
 
So I would insert the line of code you just suggested into this macro here from the slipstick article you posted above? Where in the code would I put your new line?

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
 
And do you think it's somehow possible to just select individual contacts as well as contact groups as part of one routine mail merge, then create an email mail merge in a way that individual contacts would continue to receive individual emails as usual, but the members of each selected contact group would receive group emails? And each email title containing the first name of each recipient? The solution outlined in http://www.slipstick.com/developer/send-mail-merge-contact-groups/ will definitely suffice, but doing these kinds of combo contact/contact group mail merges would be a dream come true.
 
No, unfortunately you cant use a contact group/dl as a record in a mail merge. You need to use individual contacts.
 
I'm on my tablet so I can't test it and I'm not 100% sure. Did you try it as is?
 
Finally got a chance to test the macro in http://www.slipstick.com/developer/send-mail-merge-contact-groups/. It works for the most part, except:

1. It creates the emails but I have to hit Send on each. Is there a way to just have them sent directly to the outbox?
2. My signature icons don't make it into the emails. (see pic)
3. Occasionally it will remove the emails associated with the name. For instance, in the pic you'll see that 1146 Miles is a contact group but once the macro creates the email, '1146 Miles' is just text, not a contact group. I have to manually re-add the contact group 1146 Miles to that email to have it sent successfully.

Finally, how would I adjust the macro code so that the FullName field of each contact group appears in each email title where I'd type <Full_Name> so we can personalize these babies?

Exciting...!
 

Attachments

  • Capture.JPG
    Capture.JPG
    23 KB · Views: 512
This line: objMsg.Display is set for testing. change display to send when you wan to send it.

If the group is in contacts, outlook *should* resolve it on send. It's actually supposed to resolve it in the code -
For Each objOutlookRecip In objMsg.Recipients
objOutlookRecip.Resolve
Next

I think you can use objItem.GetMember(i).Name to get the DL name. But the merge doesn't support DLs, so you'd need to use bookmarks and VBA to send the name to the body.

I'm not sure on the images - they should work though. I'll have to test it.
 
See the attached pic for the error code I receive when I change objMsg.Display to objMsg.Send.

Where in this code do I insert objItem.GetMember(i).Name in order to have the DL's fullname inserted in each email title? I don't need to send the name to the body, just the email titles.
 

Attachments

  • error.JPG
    error.JPG
    93.2 KB · Views: 564
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
L Error when exporting Sent Mail to Excel Outlook VBA and Custom Forms 6
X Run macro automatically when a mail appears in the sent folder Using Outlook 5
K How can I delete an e-mail from Outlook Using Outlook 1
L Help: set flag for sent mail to check if received an answer Outlook VBA and Custom Forms 2
A Macro Mail Alert Using Outlook 4
e_a_g_l_e_p_i MY Outlook 2021 changed the format of the shortcuts for mail, calendar etc. Using Outlook 10
Z Outlook 365 Automatically assign categories to incoming mail in a shared folder Round Robin Outlook VBA and Custom Forms 1
W Outlook 365 I am getting the "Either there is no default mail client" error when I try to send an email on excel Office 365 Using Outlook 1
D Gmail mail is being delivered to a different email inbox in Outlook App 2021 Using Outlook 2
P What is your strategy for dealing with SPAM and Junk Mail? Using Outlook 1
C Code to move mail with certain attachment name? Does Not work Outlook VBA and Custom Forms 3
T 1:1 Datatransfer from incoming mail body to customs form body Outlook VBA and Custom Forms 0
O Mail rule issue Using Outlook 3
A manual rule sends mail to wrong folder Using Outlook 5
Aussie Outlook 365 Rule runs manually but returns the error code "an unexpected error has occurred" when incoming mail arrives Using Outlook 1
D ISOmacro to extract active mail senders name and email, CC, Subject line, and filename of attachments and import them into premade excel spread sheet Outlook VBA and Custom Forms 2
Witzker Outlook 2019 Macro to answer a mail with attachments Outlook VBA and Custom Forms 2
D Outlook 2003 Mail Fails Using Outlook 1
Cathy Rhone Mail merge error message Using Outlook 1
R Sent emails show iCloud mail account not the alias Using Outlook 2
D Advanced e-Mail search on from/to contact group only searches for first 20 contacts in group Using Outlook 0
P Print attachments automatically and move the mail to an existing folder called "Ted" Outlook VBA and Custom Forms 4
P Importing other e-mail accounts into Outlook Using Outlook 1
lcarpay Stay in the mail folder pane after ctrl-1 Using Outlook 1
O Exchange Sync period only (e.g. last years mail) Using Outlook 0
F Excel VBA to move mails for outlook 365 on secondary mail account Outlook VBA and Custom Forms 1
M Convertor for Outlook Express Mail Store (.dbx) to Outlook Mail Store (.pst) Using Outlook 0
T vba extract data from msg file as attachment file of mail message Outlook VBA and Custom Forms 1
J E-mail held in Outbox while Minimized Using Outlook 3
G Forward email body to other mail list directly from Exchange server Exchange Server Administration 1
T Outlook creates a copie of every mail I send Using Outlook.com accounts in Outlook 4
N Please advise code received new mail Using Outlook 0
M Outlook 2010 How could I globally redesign an outlook template form/region/inspector template used to display mail lists or an individual mails? Outlook VBA and Custom Forms 0
A How to stop user form from disapearing once mail window is closed? Outlook VBA and Custom Forms 0
M Outlook, send to > mail recipient - results in plain text email Using Outlook 1
R How to Sync *all* Google Workspace Mail Folders with Outlook 2019 (MS365) Using Outlook 3
S Outlook VBA How to adapt this code for using in a different Mail Inbox Outlook VBA and Custom Forms 0
E Having some trouble with a run-a-script rule (moving mail based on file type) Outlook VBA and Custom Forms 5
S Outlook email to configure setup for each mail Outlook VBA and Custom Forms 1
L Correct E-Mail Pulling Wrong Mail Using Outlook 5
S Outlook mail adressing stops after first match in GAL Using Outlook 0
P Outlook 2013 All imported Mail Rules in error when imported into new profile Using Outlook 5
S Outlook Macro to send auto acknowledge mail only to new mails received to a specific shared inbox Outlook VBA and Custom Forms 0
S Outlook Macro to move reply mail based on the key word in the subjectline Outlook VBA and Custom Forms 0
MrMayor SENT mail not reloading to top?? Using Outlook 4
Terry Sullivan Sender Field Displays My E-Mail Address, Not My Name Using Outlook 1
ThinkToday Calculate reply time of outlook mail Using Outlook 1
B Outlook 2010 Opening Mail Attachment Using Outlook 2
e_a_g_l_e_p_i Is it possible it set the fonts used to read incoming mail Using Outlook 25
D Mail in Sent Items Gone Using Outlook 12

Similar threads

Back
Top