3

Sometimes in Outlook I want to be able to see the last few emails I received or sent to a client.

As there can be several individual email addresses per client, the only way to reliably identify emails as belonging to a client is to look at the domain part of the email address, eg the company in person@company.com

How can I add this as a sortable column in the main views (Inbox, Sent Items, etc)?

userSteve
  • 1,554
  • 1
  • 22
  • 34

3 Answers3

4

Almost found what I want from here (I've improved on the formula).

Add a new column to a view from the Show Columns dialog, click New Column and enter a new formula based column:

IIf(InStr([SearchFromEmail], "@") = 0, "", Mid([SearchFromEmail], InStr([SearchFromEmail], "@") + 1))

Similar question was asked here https://superuser.com/questions/703013/outlook-how-to-display-sender-email-address-in-inbox/703035#703035

userSteve
  • 1,554
  • 1
  • 22
  • 34
  • The problem with this method is that these custom column are not sortable of filterable. Outlook will only filter/sort on columns that return an intrinsic data element that is part of the stored Item (e.g. the "From", "To", "Received" etc.). To make a custom column that Oultook will sort, you have to create a new Item Property and add it to the Item. You can use VBA to extract text from the original Item, then apply it as a property, then add a column to display that property. Very annoying, given this idea is pretty basic... – skeetastax Sep 04 '20 at 01:27
0

Not out of the box. You can process all your existing emails (and automatically process all new items using MAPIFolder.Items.ItemAdd event on the folders that you want to process) to set a user property (MailItem.UserProperties.Add) to the value extracted by your code. If you modify the folder views to include your property, you will be able to see it.

Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78
0

Be aware, the ItemAdd event of the Items class is not fired when multiple items are added to the folder at the same time.

You can handle the NewMailEx event of the Application class which is fires when a new message arrives in the Inbox and before client rule processing occurs. You can use the Entry ID returned in the EntryIDCollection array to call the NameSpace.GetItemFromID method and process the item.

In the event handler you can add a user property which can be user in the UI for sorting items (MailItem.UserProperties.Add). The CurrentView property of the Folder class returns a View object representing the current view.

The View object allows you to create customizable views that allow you to better sort, group and ultimately view data of all different types. There are a variety of different view types that provide the flexibility needed to create and maintain your important data. - The table view type (olTableView) allows you to view data in a simple field-based table. - The Calendar view type (olCalendarView) allows you to view data in a calendar format. - The card view type (olCardView) allows you to view data in a series of cards. Each card displays the information contained by the item and can be sorted. - The icon view type (olIconView) allows you to view data as icons, similar to a Windows folder or explorer. - The timeline view type (olTimelineView) allows you to view data as it is received in a customizable linear time line.

Views are defined and customized using the View object's XML property. The XML property allows you to create and set a customized XML schema that defines the various features of a view.

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45