The default email display name in the address book used to be "Full Name (Email1)", "Full Name (Email2)", "Full Name (Email3)" but was changed to "Full Name (email address)". If you upgraded from an earlier version of Outlook, your contacts may use a mix of display name formats. The code below will allow you to easily convert all contacts to a uniform format or remove the address for security reasons, per a discussion in TechNet forums:
Using the File As... format without (email address) displayed, when people forward emails, messages will not contain the email address visible for others, just the display name, or not accessible for worms or other user's mailbox attackers.
This code sample works on the Display name for the default email address (Email1) but can easily be changed to work with Email2 or Email3.
This code sample was created from Change Contact's File As format
To change the File as format on existing contacts, see Bulk Change File As Format for Contacts. Our third "Bulk change Contacts" VBA sample is at Bulk Move Phone Numbers to a Different Phone Field.
The Name column (1) is controlled by the Address book setting. Column 2, the email Display Name, defaults to Full Name (email address) format. The code on this page will change this field.
To change the Name column (1) in Outlook 2007, the options for the Name column format is at Tools, Account Settings, Address book Tab, double click on the Outlook Address book and choose between Full name or File as format. In Outlook 2010, you'll start at File, Account Settings, Address book Tab, double click on the Outlook Address book. In Outlook 2003 or 2002, go to Tools, Email Accounts, View or Change existing directories or address books. Select Outlook Address Book and click Change to view or change the default for new contacts.
Note that when you edit a contact's email address, the display name is rewritten using Outlook's default format. You'll need to edit it before saving the contact.
While you can't change the default settings for the Display Name field (it always uses 'Full name (address)' format), you can use VBA to change your contacts so they all use the same format. Your choices are limited to Full name, Last First, FileAs, and Company. You can include the email address by adding this code to the format code: & " (" & .Email1Address & ")".
Default email display name format:
After running the VBA code below:
When you click the To button, the entry in the Address book will now look like this:
Not up to working with VBA code? See Tools for tools that can make this change.
Two formats in the code sample below are less than useful as Display name formats:
strFileAs = .CompanyName & " " & .FullName & " (" & .Email1Address & ")"
Results in a leading space if the Contact does not have a Company listed.
'strFileAs = .FileAs
Uses only the Company name in the display name when the FileAs format is "Company name (Fullname)".
Note: I updated the code below to check for email addresses. If an address does not exist, the contact is skipped.
VBA Code to Change the Email Display Name
Press Alt+F11 to open the VBA editor then copy and paste into ThisOutlookSession. Uncomment the strFileAs line that uses the format you desire before running it.
This code was tested with Outlook 2010, 2007, and 2003. (May trigger the Email security prompts in Outlook 2003.)
If you have multiple contacts folders, ChangeEmailDisplayName_SelectedContacts will change the selected contacts. It checks for an email address (If .Email1Address <> "" Then) and only updates contacts with email addresses.
Public Sub ChangeEmailDisplayName() Dim objOL As Outlook.Application Dim objNS As Outlook.NameSpace Dim objContact As Outlook.ContactItem Dim objItems As Outlook.Items Dim objContactsFolder As Outlook.MAPIFolder Dim obj As Object Dim strFirstName As String Dim strLastName As String Dim strFileAs As String On Error Resume Next Set objOL = CreateObject("Outlook.Application") Set objNS = objOL.GetNamespace("MAPI") Set objContactsFolder = objNS.GetDefaultFolder(olFolderContacts) Set objItems = objContactsFolder.Items For Each obj In objItems 'Test for contact and not distribution list If obj.Class = olContact Then Set objContact = obj With objContact If .Email1Address <>"" Then ' Uncomment the strFileAs line for the desired format ' Add the email address to any string using ' the following code: ' & " (" & .Email1Address & ")" 'Firstname Lastname (email address) format ' strFileAs = .FullName & " (" & .Email1Address & ")" 'Lastname, Firstname format strFileAs = .LastNameAndFirstName 'Company name (email address) format ' strFileAs = .CompanyName & " (" & .Email1Address & ")" 'Comapany Firstname Lastname (email address) format 'the display name will have a leading space if 'the contact doesn't have a company name 'strFileAs = .CompanyName & " " & .FullName & " (" & .Email1Address & ")" 'File As format 'Does not support Company (Fullname) format. 'Only Company name is used in the display name 'strFileAs = .FileAs .Email1DisplayName= strFileAs .Save End If End With End If Err.Clear Next Set objOL = Nothing Set objNS = Nothing Set obj = Nothing Set objContact = Nothing Set objItems = Nothing Set objContactsFolder = Nothing End Sub
How to use the Macro
First: You will need macro security set to low during testing.
To check your macro security in Outlook 2010 and newer, 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. If Outlook tells you it needs to be restarted, close and reopen Outlook. Note: after you test the macro and see that it works, you can either leave macro security set to low or sign the macro.
Now open the VBA Editor by pressing Alt+F11 on your keyboard.
To put the code in a module:
- Right click on Project1 and choose Insert > Module
- Copy and paste the macro into the new module.
More information as well as screenshots are at How to use the VBA Editor.
ContactGenie Toolkit: 28 functions for Outlook 2000-2010 enabling changes to individual standard and custom fields; standardization for Message Class, CompanyName, FileAs, EmailDisplayAs, Fullname, and other fields; contact and NK2 info export; export contacts to CSV file; global changes for CompanyName, Company Address, Email and Web addresses. Preview/override any pending changes. Add Birthday/Anniversary/user-defined dates to default calendar. Personal Distribution Group management and more.
More Bulk Change Contact articles at Slipstick.com:
- Bulk Change Contact's FileAs Format to Match Outlook's Default Setting
- Bulk Change File As Format for Contacts
- Bulk Move Phone Numbers to a Different Phone Field
- Macro to Swap First and Last Name Fields
- Show the Home Address on a Contact Form by Default
- Update Contact Area Codes
- Update Contacts with a New Company Name and Email Address