Twitter user Samuli Hiltunen (@smuli) asked me if there is a way to have the sender’s email address appear in an Outlook view. The quick answer is no. Although the sender’s email address is included in an email (that’s obvious since you couldn’t reply without it) Microsoft didn’t make it available in the list of fields you can include in a view. Making the field available to a view requires some scripting (i.e. a macro). The macro is quite simple though. For each message that arrives it creates a user-defined property and inserts the sender’s email address in it. User-defined properties are available to views, so once the macro is in place all Samuli need do is add the user-defined field to the view.
Follow these instructions to add the code to Outlook.
- Start Outlook
- Click Tools > Macro > Visual Basic Editor
- If not already expanded, expand Microsoft Office Outlook Objects
- If not already expanded, expand Modules
- Select an existing module (e.g. Module1) by double-clicking on it or create a new module by right-clicking Modules and selecting Insert > Module.
- Copy the code below and paste it into the right-hand pane of Outlook’s VB Editor window
- Click the diskette icon on the toolbar to save the changes
- Close the VB Editor
Private Sub AddSenderAddress(Item As Outlook.MailItem) Dim olkPrp As Outlook.UserProperty On Error Resume Next Set olkPrp = Item.UserProperties.Add("SenderAddress", olText, True) olkPrp.Value = Item.SenderEmailAddress Item.Save On Error GoTo 0 Set olkPrp = Nothing End Sub
The next step is to create a rule that triggers the macro. Here’s how to do that.
- Click Tools > Rules and Alerts.
- Click New Rule
- Select Check messages when they arrive under Start from a blank rule
- Click Next
- Leave the condition blank and click Next
- Click Yes in answer to the warning that the rule will run for every message
- For an action select run a script by checking the box next to that option
- Click the blue underlined a script in the lower pane of the dialog box and select AddSenderAddress as the script to run
- Click Finish
The last step is to modify the view by adding the user-defined field called SenderAddress. Wait until you’ve received at least one email before modifying the view. The user-defined field won’t exist until the rule has run the first time and created the field. Once a message has arrived, then follow these steps to add the field to the view.
- Go to the Inbox
- Click View > Current View > Customize Current View
- Click Fields
- Click the Select available fields pulldown and select User-defined fields in Inbox
- In Available fields select SenderAddress then click Add
- Use the Move Up and Move Down buttons to position the field where you want it
- Click OK twice
You should now see the sender’s email address in the view.