IndySockets / Indy

Indy - Internet Direct
https://www.indyproject.org
448 stars 153 forks source link

TIdIMAP4: RFC 6154: Add a version of ListMailboxes that return also the mailbox' flags #538

Open infpmandin opened 2 months ago

infpmandin commented 2 months ago

TIdIMAP4 ListMailboxes only return the list of mailboxes in the account.

The IMAP4 LIST command used parses the result and only return the mailbox names. Could be useful to have an extended version that also gives back the flags (i.e. sent, draft, trash, etc) set to each mailbox.

Currently the only workaround would be to SelectMailbox() each one of these to get the flags.

rlebeau commented 2 months ago

Funny, there is already a TODO in the code for this very feature:

//Todo: Get mail box attributes here
{CC2: Could put mailbox attributes in AMBList's Objects property?}

That comment has existed since Indy 9. It was just never implemented yet.

Obviously, using the caller's TStrings.Objects property for output would not be a good idea. Will probably have to define a new TCollection class for this purpose, similar to TIdImapMessageParts used in various Retreive methods.

Whatever solution is created should also be applied to ListInferiorMailBoxes() and ListSubscribedMailBoxes() as well.