Friday 14 October 2016

Replace Display Names with Email Addresses

In a long thread discussing the problem of Outlook not showing the recipients email address atHow to show email address not just name in From and To fields a user mentioned the steps he uses to get around this problem:
I need the full email address displayed when I print a sent email so that I can prove exactly what email address it was sent to. So instead of TO: 'John Doe' it will print out as john@domain.com. Right now when replying to an email, or starting a new one, I have to double click on 'John Doe ' and copy the full email address and paste it into the TO field. Otherwise it will print out as John Doe.
print header with names
Outlook uses the display name in the To/CC/BCC fields, getting it from the message you are replying to, or from the Email Display Name field in Contacts. Newer versions of Outlook will use Full Name (email@domain.com) as the display name format in Contacts but senders almost always use their name as the display name and don't include the email address. While newer versions of Outlook display the email address when you are composing mail, when the message is sent, only the display name is visible.
This specific problem is easy to solve using an ItemSend macro. Before the message is sent, the macro changes display names to the underlying email address. If the recipient entry contains an @ sign, it's skipped (remove the If/End If lines if you use @ signs in display names). It's completely automatic - as soon as you press Send, the display names are changed to the email address.
print header with addresses
VBA
18 lines
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim Recipients As Outlook.Recipients
Dim R As Outlook.Recipient
Dim i
Set Recipients = Item.Recipients
For i = Recipients.Count To 1 Step -1
Set R = Recipients.Item(i)
' if the entry is already an address, skip it
If InStr(1, R, "@") = 0 Then
Recipients.Add R.Address
Recipients.Remove i
End If
Next
Recipients.ResolveAll
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 or above, go to File, Options, Trust Center and open Trust Center Settings, and change the Macro Settings. In Outlook 2007 and older, it’s atTools, 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 use the macro code in ThisOutlookSession:
  1. Expand Project1 and double click on ThisOutlookSession.
  2. Copy then paste the macro into ThisOutlookSession. (Click within the code, Select All using Ctrl+A, Ctrl+C to copy, Ctrl+V to paste.)

0 comments:

Post a Comment