The Selected State
Once a mailbox has been selected via either a SELECT or an EXAMINE command, the IMAP session enters the selected state. From here, the client may operate on mail messages themselves. If the mailbox has been selected for writing, the client can make permanent changes to the messages in the mailbox.
Commands available in the Selected State give the client the ability to gain access to message contents, search messages or parts of messages for strings, change the values of certain message parts, and copy messages. Additionally, some housekeeping commands (CHECK and CLOSE) exist in this state to allow for implementation dependent actions and to close the mailbox. The CHECK command can be issued to a server to allow the server to write files to disk (if it needs to do so) or take any other sort of action that it deems necessary. The CLOSE command closes a mailbox, which should be done before another mailbox is opened. A server can close a mailbox automatically if a new mailbox is selected.
Because messages that are compliant with the MIME standard can be quite complex, having many nested entities, the FETCH and SEARCH commands are themselves complex. This complexity exists in order to allow clients to download or search only parts of messages in order to speed actions across slow network connections. For example, one might not want to download a 3 MB attachment over a modem. IMAP allows for clients to operate on messages at a distance without having access to all message ...