IMAP: LIST, XLIST and LSUB

In IMAP protocol there are two commands to retrieve a folder list from the remote server. Most servers use LIST command, some servers support XLIST command (e.g. Gmail).

XLIST provides additional folder flags such as Inbox or Spam (which are very useful if folder names are localized to know the purpose of the folder).

Mail.dll automatically uses XLIST if it is supported by the server. You can read more about XLIST here:
/blog/localized-gmail-imap-folders

Unfortunately when you ask for subscribed folders with LSUB command, those additional flags are not send by the server. There is no such thing as XLSUB command.

The only way to workaround this limitation is to first download all folders with flags using XLIST, then use LSUB to get subscribed folders and finally match the flags by name.

Tags: , ,

Questions?

Consider using our Q&A forum for asking any questions.