IMAP is technically an asynchronous protocol, but TIdIMAP4
is currently implemented as a synchronous client. As such, unexpected/out-of-order data is either discarded, treated as untagged data, or treated as error data, depending on timing and context. Untagged/extra data is accessible from the TIdIMAP4.LastCmdResult
property, which you can type-cast to TIdReplyIMAP4
to access its Extra
sub-property.
IDLE
is not currently supported in TIdIMAP4
. There are tickets in Indy's issue trackers (see here and here) to add IDLE
support in a future release, maybe in Indy 11. Until then, you will have to poll the mailbox envelopes periodically, keeping track of messages you have already seen so you can detect new messages.