If you would like to quickly insert the recipient names to the body when composing an email, you can read this article. Here we will introduce you a convenient method.
At times, you may need to input the names of all recipients to the body when you are composing an email. Undoubtedly, it’s considerably tedious and cumbersome to extract and insert the names to body one by one manually. Therefore, in order to help you accomplish it rapidly, here we’ll share you an efficient means. Read on to get its detailed steps.
Insert Recipient Names to Email Body
- For a start, access VBA editor via “Alt + F11”.
- Then, in the “Microsoft Visual Basic for Applications” window, enable “MS Word Object Library” according to “How to Add an Object Library Reference in VBA“.
- Next, copy the VBA code below into an empty module.
Sub CopyRecipientNamesToBody() Dim objMail As Outlook.MailItem Dim objRecipient As Outlook.Recipient Dim strRecipAddress As String Dim strRecipName As String Dim objContacts As Outlook.Items Dim i As Integer Dim strFilter As String Dim objFoundContact As Outlook.ContactItem Dim strRecipNames As String Dim objMailDocument As Word.Document 'Get the current email Set objMail = Application.ActiveInspector.CurrentItem objMail.Recipients.ResolveAll For Each objRecipient In objMail.Recipients strRecipAddress = objRecipient.Address 'Get the corresponding contact name Set objContacts = Application.Session.GetDefaultFolder(olFolderContacts).Items For i = 1 To 3 strFilter = "[Email" & i & "Address] = " & strRecipAddress Set objFoundContact = objContacts.Find(strFilter) If Not (objFoundContact Is Nothing) Then strRecipNames = strRecipNames & objFoundContact.FullName & vbCr Exit For End If Next 'If there isn't associated contact 'Extract name from email address If objFoundContact Is Nothing Then strRecipName = Split(strRecipAddress, "@")(0) strRecipName = UCase(Left(strRecipName, 1)) & Right(strRecipName, Len(strRecipName) - 1) strRecipNames = strRecipNames & strRecipName & vbCr End If Next 'Insert the names at the beginning of email Set objMailDocument = objMail.GetInspector.WordEditor objMailDocument.Range(0, 0).InsertAfter strRecipNames End Sub
- Next, add this macro to Quick Access Toolbar of Message window according to the optional step in “How to Run VBA Code in Your Outlook“.
- After that, exit the window.
- Finally, take a shot.
- First off, compose an email and fill in recipients.
- Then, hit the macro button in Quick Access Toolbar.
- When macro finishes, the recipient names have been inserted in email body, as shown in the figure below.
Guard against Outlook Damage
Since Outlook is vulnerable, it’s difficult to protect Outlook from damage. With no doubt, you must be reluctant to encountering PST corruption. Therefore, you had better take some effective precautions. For example, you need to make consistent data backups for Outlook, be familiar with how to use inbox repair tool as well as keep a powerful external tool in vicinity, such as DataNumen Outlook Repair.
Author Introduction:
Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including SQL Server fix and outlook repair software products. For more information visit www.datanumen.com
Leave a Reply