I'm trying to retrieve messages by sorted by date, using the JavaMail API. Here
is my code:
try (Store store = connectToMessageStore(username, password);
IMAPFolder emailFolder = (IMAPFolder)store.getFolder("INBOX")) {
emailFolder.open(Folder.READ_ONLY);
messageCount = emailFolder.getMessageCount();
Message[] messages = emailFolder.getSortedMessages(new SortTerm[]
{SortTerm.DATE}); //THIS IS THE LINE THAT IS FAILING
messageList = getMessageConverter().toMessageSummary(messages);
} catch (MessagingException e) {
LOGGER.error(ERROR_READING_EMAIL_MESSAGES, e.getMessage());
throw new MessagingServiceException(e);
}
This is the error in my logs:
"Servlet.service() for servlet [dispatcherServlet] in context with path []
threw exception [Request processing failed; nested exception is
aero.sita.ir.communicator.messaging.MessagingServiceException:
javax.mail.MessagingException: SORT not supported;\n nested exception
is:\n\tcom.sun.mail.iap.BadCommandException: SORT not supported] with root
cause"
My intention would be to page the results after sorting.
Best Regards,
Sean
-----Original Message-----
From: Matthieu Baechler <[email protected]>
Sent: Thursday 14 May 2020 07:58
To: James Users List <[email protected]>
Subject: [EXT] Re: Java Mail API Sort
Hi Sean,
On Wed, 2020-05-13 at 16:27 +0000, Sean McElroy wrote:
> Hello,
>
> Is there any way to configure James so that it supports the
> com.sun.mail.imap.IMAPFolder getSortedMessages method?
Could you tell us what you are trying to achieve and how? Do you have some code
snippet to show us maybe?
> Thanks,
> Sean
>
> Confidential Communication: The contents of this e-mail including any
> attachment are confidential and intended solely for the person(s) to
> whom they are addressed. Any reader of this email who is not the
> intended recipient is notified that any dissemination, distribution or
> copying of this communication is strictly prohibited. If you have
> received this e-mail in error, please notify the sender immediately
> and delete all copies from your computer system. Subsequent
> alterations to this email after its transmission will be disregarded.
Well, this kind of legal footer has no place on a mailing list, could you
configure your mailer agent to avoid sending that as it's irrelevant in that
context?
Cheers,
--
Matthieu Baechler
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
Confidential Communication: The contents of this e-mail including any
attachment are confidential and intended solely for the person(s) to whom they
are addressed. Any reader of this email who is not the intended recipient is
notified that any dissemination, distribution or copying of this communication
is strictly prohibited. If you have received this e-mail in error, please
notify the sender immediately and delete all copies from your computer system.
Subsequent alterations to this email after its transmission will be disregarded.