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
- For a start, you should turn to “Developer” tab in Outlook.
- Then under this tab, you can locate and click on “Visual Basic” button.
- After that, a new “Microsoft Visual Basic for Applications” window will open. Now you should open a new module by clicking “Insert” > “Module”.
- 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
- 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.
- 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.
- 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:
- And next you will receive a message box, which demands you to 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.
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.
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
Leave a Reply