I've noticed a peculiar behavior regarding the IMAP \Answered flag. I'm using DavMail 5.4.0-3135 to connect Thunderbird to a corporate O365 account using O365Interactive via EWS. For testing purposes, I have TB configured with two accounts: One uses the traditional IMAP protocol direct to O365, and the other connects to the same O365 account via DavMail. The O365 account has been in use for a long time, with many messages stored.
Curiously, some of the previously existing messages show up in TB/DavMail without the "Replied To" left arrow in the message list pane that they have in the direct IMAP connection. (And some do have it as expected.)
At first, I wasn't sure if it was a problem with O365, DavMail, or TB, so I dug further. I used openssl to create interactive sessions to both O365/IMAP and DAVMAIL/IMAP to see if the IMAP \Answered flag was supported and behaving as expected. For comparison, I also looked at the "\Seen" flag, which seems to behave exactly as expected.
For \Seen, I can set or unset this flag in O365/IMAP, or DavMail, and the changed flag is observed in both places. (For DavMail, I have to re-SELECT the folder to refresh the status of flags changed externally first.)
For \Answered, I can set or unset the flag in either case too. However, the change is only seen via the access method that changed it. If I change it in O365/IMAP, the change is not seen in DavMail/IMAP. If I change it in DavMail, I do see it changed there, but not in O365/IMAP.
So it's starting to look like a bug or "feature" of O365 in that the state of this "flag" is stored separately for the IMAP and EWS access into the same mailbox, and synchronization of the two is only partially working. (As evidenced in that some of my old messages DO show this flag via DavMail.)
I thought I would ping the DavMail developers to tap into their much greater knowledge and experience with O365 to see if they have any insight into this.
Interesting, DavMail flag implementation is based on two MAPI properties:
PidTagLastVerbExecuted, PR_LAST_VERB_EXECUTED, ptagLastVerbExecuted
PidTagIconIndex, PR_ICON_INDEX, ptagIconIndex
This implementation is quite old (back to old Exchange 2003/2007 over WebDav) and finely tuned to match Outlook behaviour.
However this was not compared with Exchange native IMAP support. According to your tests IMAP support seem to be different. You can check exact message properties values with EWSEditor.
Maybe the issue is related to PidTagLastVerbExecutionTime ?