Problem: Whenever I retrieve emails from the mail server, regardless of the number of emails I request, the most recent emails are always returned last. However, I would like the first email in the query result to be the most recent one.
Details: Currently, when I fetch emails from the server, I use the standard method provided by K-9 Mail. Regardless of whether I fetch a small or large number of emails, the newest emails are consistently placed at the end of the result. This makes it less efficient for my use case, where I need to process the most recent emails first.
Desired Outcome: I want to modify the behavior so that when I query the mail server, the first email in the result is the one with the most recent date. This would optimize my workflow, as I need to prioritize the latest emails for processing.
Question: Could you please guide me on which part of the code I should modify to achieve this behavior? If there’s a specific method or parameter that I need to adjust, I’d appreciate your help in pointing me in the right direction.
The latest message should always be fetched first. Are you sure you didn’t just accidentally change the sort order of the message list? Tap the “sort” icon (three horizontal lines, getting shorter from top to bottom) in the toolbar when viewing the message list to change the sort order.
This is unrelated to settings. I’ve checked it by adding logs in the fetch method of RealImapFolder . Regardless of how I sort my query list, the fetchList returned by this code snippet:
val fetchList = response.getKeyedValue(“FETCH”) as ImapList
always gives me the oldest email information as the first message. I would like to modify which parameter in this method to make sure that the method returns emails with the latest dates.
K-9 Mail requests a list of messages from the server. It’s up to the server in which order it responds. As far as I can tell the only way to work around this is to issue one command per message that should be downloaded. However, this could significantly increase the amount of data that is sent to the server, and it slightly increases the amount of data sent from the server.