While this reason for this article no longer exists now that Exchange ActiveSync connectivity to Outlook.com has been shut down, this macro remains a useful example demonstrating how to read a message header using a macro.
You can view the Internet Header in the File, Properties dialog, in a really tiny text box. (You can save a step by adding the Message Properties command the ribbon. It's under All Commands when you customize the ribbon.)
To make it easier to see the just the recipients, use a macro to display the CC or BCC addresses in a message box. Create a button on the ribbon to run the macro, then select a message and click the button to display a message box containing the BCC addresses.
If you need a copy of the recipients, click on the message box and press Ctrl+C to copy.
Sub ViewBCCAddresses() Const PR_TRANSPORT_MESSAGE_HEADERS = "http://schemas.microsoft.com/mapi/proptag/0x007D001E" Dim olMail As Outlook.MailItem Dim Reg1 As Object Dim M1 As Object Dim M As Object Dim strHeader As String Dim strBCC As String Dim olkPA As Outlook.PropertyAccessor On Error Resume Next Set olMail = Application.ActiveExplorer.Selection.Item(1) Set olkPA = olMail.PropertyAccessor strHeader = olkPA.GetProperty(PR_TRANSPORT_MESSAGE_HEADERS) Debug.Print strHeader Set Reg1 = CreateObject("VBScript.RegExp") With Reg1 .Pattern = "(CC[:]\s(.*)\n)" .Global = False End With If Reg1.test(strHeader) Then Set M1 = Reg1.Execute(strHeader) For Each M In M1 strBCC = M.SubMatches(1) MsgBox strBCC Next End If Set M = Nothing Set M1 = Nothing Set Reg1 = Nothing Set olMail = 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 2013, go to File, Options, Trust Center and open Trust Center Settings, and change the Macro Settings.
After you test the macro and see that it works, you can either leave macro security set to low or sign the macro.
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.
- Go to File, Options, Customize Ribbon
- On the right, select Home then click New Group
- Select Macros from the Choose Commands From dropdown
- Select the ViewBCCAddresses and click Add to add it to the group.
- Click Rename to give the button a friendly name and select and icon.
More information as well as screenshots are at How to use the VBA Editor