Date Sent or Date Received?

I’m puzzled by K-9 Mail’s display of incoming messages with respect to Date Sent and Date Received. This regularly causes me (and I’m sure others) a lot of confusion. I suspect there are different technical reasons for inconsistent behavior depending on the email service and protocol, so I’ll start with the problem as manifest in an Outlook account (for work).

As an example, yesterday morning, a colleague scheduled a message to be sent today.* I received it this morning, but in K-9 Mail, it shows up under yesterday’s date. The message was a reminder about an event today, so seeing yesterday’s date on the message made me think I missed the event!

In this case, it would make more sense if K-9 Mail used the date the app received the message rather than the date the sender set up the scheduling.
Is this a bug?
Is there an option to choose which date is used in the inbox?

*I believe the desktop versions of Outlook have allowed scheduling when to send email for some time, but this feature has recently been added the Outlook on the web, so it’s seeing more use now.

By default K-9 Mail sorts messages using the value of the Date header field.

You can also sort the message list by “arrival” date. This is a bit more fuzzy. For IMAP accounts it’s the “internal date” from the server and usually the time when the message arrived. If the server doesn’t supply an “internal date” K-9 Mail uses the time the message was downloaded.

I don’t know how Outlook’s scheduled send feature works. I would hope it sets the Date header field to the time the message was actually sent. But from your description it sounds like they use the date the message was composed. While this is technically not wrong, it certainly doesn’t match user expectations. But it’d be up to the sender to change the way the message is generated.

I appreciate the info! However, sorting by Arrival date does something strange in this case: it puts it in the correct order of receipt, but the dates shown in the message list all stay the same, so they appear out of order. Shouldn’t changing to sort by Arrival date then show the arrival dates in the message list?

Also, I noticed for this scheduled email, the headers that appear in K-9 Mail when I tap “Show headers” are very short (just 8 lines/fields) and the only date given is the date the sender set up the scheduling (i.e., the day before it arrived). Other messages from the same sender contain the full headers in K-9 Mail (dozens of lines/fields). It seems K-9 Mail is truncating the email headers for some reason, because the same message when viewed in a web browser shows the full headers. Maybe K-9 Mail’s truncating of headers is causing some issues?

I guess that’d be less confusing. I created a feature request for that: Show arrival date in message list when sorting by arrival · Issue #5280 · k9mail/k-9 · GitHub

For emails larger than the “fetch messages up to” threshold K-9 Mail only downloads parts of the message, including only “interesting” header fields. Those messages show a “Download complete message” button at the bottom when viewing the message.
But the Date header field is always fetched and it’s the only one K-9 Mail uses for the date of the message.

To remove the confusion about missing header fields there’s this issue: Download all headers if necessary for "show headers" view · Issue #5240 · k9mail/k-9 · GitHub

It looks to me like Outlook is the issue. In my tests the web interface also used the time the message was composed for the Date header field, not the scheduled time. That’s certainly not what I would expect. There’s no (reasonable) way to distinguish such a message from one that was meant to be sent instantly but delayed due to other factors. (The Received header fields usually contain that information. But they’re only meant for manual debugging, not for extracting a display date.)

Thanks for creating that feature request and for the explanation on the short headers (makes sense).

Yes, there could be something odd with the way Outlook sends its scheduled messages, but the interesting thing is that in a web browser (and presumably in its desktop clients), Outlook is able to figure it out and display the scheduled date/time on the other end, as one would expect.

This suggests the default date/time used by Outlook’s display is not Date like K-9 but something else. Given the difficulty distinguishing between scheduled and incidentally delayed messages that you mentioned, it’s not likely from the Received header, so maybe they use something Exchange-related, such as
X-MS-Exchange-CrossTenant-OriginalArrivalTime

I’d be happy to go find and pester some Outlook developers about this, but since they have it working as expected in their ecosystem, it makes me wonder if this behavior in K-9 Mail might be a symptom of some legacy implementations that should be revisited. What do you think?

If Microsoft cared how other clients display their deferred messages they’d change the Date header (or propose a new standard way of doing deferred emails).
I’m not planning on adding support for X-MS-Exchange-CrossTenant-OriginalArrivalTime.