So for querying folders, you can simply query URL:
URL = "imap://server/"
This gives you back a result like "." and "INBOX" or other folder names.
To query list of emails, you run a custom request to fetch flags for all emails like this:
Same URL with /INBOX to specify folder and you use OptionCustomRequest with "FETCH 1:* FLAGS".
Than to query a single email, you use no custom request, but you add to URL the postfix "/INBOX/;UID=1". 1 is here the index of the email you want to query.
Now if you need to delete email, change flags or create folders, you can check the IMAP specifications and pass commands using CustomRequest option.
For next plugin version, we'll have examples showing this.