Recently one of my friends asked whether it is possible to add such a counter.
"Yes, of course. Why not?", I replied.
So today let’s see how we can add a counter for email opened/viewed. The counter will increment everytime you open any email in email window and in the preview pane.
We will add a user defined field. We will name it "Read Count" for this demo here. Then use this field to store our value.
- Right-click anywhere in the header area and select "Field Chooser" from the popup menu.
- In the Field Chooser dialog box, select "User-defined fields in Inbox" from the dropdown combobox. Then click "New…" button.
- In the New Field dialog box that comes up, type "Read Count" (without quotes) in the Name field and select Type as "Integer". Click OK to save and close the box.
- You should now see a new field named Read Count in the Field Chooser box.
Drag that field to your header area and drop it there. The new column should get added.
See screenshots below in case you have difficulty comprehending anything written above.
So now we have the new field there and will proceed to setting its value when any mail item is opened. For this, open the VBA Editor from Tools > Macros > Visual Basic Editor. Or you may simply press Alt+F11 key combination.
In the VBA Editor window, expand Microsoft Office Outlook Objects > ThisOutlookSession.
Paste the following code there:
Option Explicit Private WithEvents MyMailItem As MailItem Private Sub Application_ItemLoad(ByVal Item As Object) If TypeOf Item Is MailItem Then Set MyMailItem = Item End Sub Private Sub MyMailItem_Open(Cancel As Boolean) IncrementViewedCount End Sub Private Sub MyMailItem_Read() '-- comment out the following line if you have preview pane turned off '-- or you don’t want to increment count for emails opened in preview pane IncrementViewedCount End Sub Private Sub IncrementViewedCount() On Error GoTo ErrH If MyMailItem.UserProperties("Read Count") Is Nothing Then MyMailItem.UserProperties.Add "Read Count", olInteger, False End If MyMailItem.UserProperties("Read Count").Value = MyMailItem.UserProperties("Read Count").Value + 1 MyMailItem.Save Exit Sub ErrH: MsgBox Err.Number & Err.Description End Sub
Save everything and restart outlook. If it asks for confirmation about macros, choose to enable them.
Now whenever you open any email, you should see the Read Count increasing.