How do group by received date and display received time?

0

1

I am using Outlook 2013. By default, it groups based on the received date of Today, yesterday, days of the week, last week which really includes everything prior.

Then the received column shows m/dd/yyyy hh:mm AM/PM format. My issue is that with the date, there is too much information to be shown practically with the reading pane on.

Changing the format of the received column/field changes it for both grouping and table view.

What I am after is to group by the date and display the time in the grid/table. If I could note what is today, yesterday and maybe day of week for grouping that would be ideal but I suspect that would require more than looking at the message when it comes in which I suspect is the timing of this working.

What I think needs to be done is make an additional field for grouping purposes because I need to strip off the time otherwise it ends up grouping on date and time which will almost always be my message and therefore useless.

Where I am at a loss is, how do I populate the additional field? I assume it needs to be VBA but I am at a total loss as to how to add the code and what event could be used assuming I can do an application level event / mailitem received / mailitem added to collection. Really pointing to the event and objects involved should be enough for me to do it, I am accomplished with VBA in general but struggling with the Outlook object model/events for this area.

For completeness, the steps I think I understand..

Adding additional field would be, view ribbon, view settings, columns button, New Column -> appropriate selections - either date/time with appropriate formatting or text and relying on populating with ISO date format (yyyy-mm-dd) to maintain sort order.

Grouping would be under the Group By button at the location where columns button is.

EDIT: I did make the code work more or less. There are a few remaining issues.

'Code sample from stack overflow with enhancements
'Revised With typo correcton - works, sort of
Private WithEvents Items As Outlook.Items
Private Sub Application_Startup()
  Dim olApp As Outlook.Application
  Dim objNS As Outlook.NameSpace
  Set olApp = Outlook.Application
  Set objNS = olApp.GetNamespace("MAPI")
  ' default local Inbox
  Set Items = objNS.GetDefaultFolder(olFolderInbox).Items
End Sub

Private Sub Items_ItemAdd(ByVal item As Object)

  On Error GoTo ErrorHandler
  Dim dtReceived As Date
  Dim Msg As Outlook.MailItem
  Dim objProp As Outlook.UserProperty
  If TypeName(item) = "MailItem" Then
    Set Msg = item

        'My Code
    dtReceived = Msg.ReceivedTime
    'MsgBox "Date Received is" & dtReceived 'Yes it is running, an early diagnostic line removed
    Set objProp = item.UserProperties.Add("ReceivedDateOnly", olDateTime, True)
    objProp.Value = DateSerial(Year(dtReceived), Month(dtReceived), Day(dtReceived))
    Msg.Save 'Mailitem needs saved now that it has been updated
'Last of my original code

  End If
ProgramExit:
  Exit Sub
ErrorHandler:
  MsgBox Err.Number & " - " & Err.Description
  Resume ProgramExit
End Sub

Remaining Issues:

  1. Code only fires when message received and will not update messages already in your OST/PST (stuff on your computer) - I did get around this by killing my ost and letting it process everything again (because an OST is local copy of what is on the Exchange Server, may not be advisable with PST)... Not a quick thing if you have a large number of e-mails as I do because it is going in and modifying them after downloading and then saving the change... This is more of a watch out for others as the boat has sailed for me. A good idea would be to write code to loop over the mailbox mirroring the process but I am not doing that now.
  2. The Format Columns button has no effect on the field appearing in group heading. Because a date without a time is effectively midnight, the first moment of the day, it displays as "ReceivedDateOnly: DDDD, MMMM DD, YYYY 12:00AM: X items(s) Y unread". While this is a huge improvement to me it is less than ideal. Given you have to tell it to show the group field to see the date, anyone else using this may want to consider a revised shorter field name.
  3. Saving the worst for last, it only works on mailitem objects which is to say regular e-mails. It does not do anything to calendar style "e-mails" (meeting invites). When grouping then, the userdefined field is not changed when received and instead of showing a date for the section, it shows "None". Since you are obviously sorting Descending to show most recent first, this puts it at the bottom of the list.

Outside of that last issue, I am tolerating it and enjoying seeing the received date as time. Clearly my code needs enhanced for the other type. I know what to dig around with to fix it but I am tabling the issue for now and welcome insight or fixes for any of the issues.

Jason

Posted 2018-01-24T15:56:59.587

Reputation: 1

You seem to have created two accounts. Please check with Help Centre to merge your accounts – Dave M – 2018-01-24T19:29:17.250

First of all, welcome to Super User! We are always glad to help, but you apparently have two Super User accounts: this one and this one. Please take the time to utilize the following Help Center tutorial and ask the Super User staff to merge your accounts: I accidentally created two accounts; how do I merge them?

– Run5k – 2018-01-24T19:51:22.920

You can freely edit your own posts but for your protection, this must be done under the original user account. It looks like you have created a second account, which will also interfere with your ability to comment within your thread and to accept an answer. See Merge my accounts to get your accounts merged, which will solve the problem.

– fixer1234 – 2018-01-26T01:31:58.570

No answers