Messaging Endpoint
  Email caching is used to speed up access to frequently used IMAP email accounts.    github_example
  The basis of the functionality is a more or less permanent cache of the email headers.

It consists of the following methods:
  Before you can cache an account you need to set the cachetype field to either 1 (headers) or 2 (full). This is used to control whether:
  • just the headers are cached by default (eg subject, from, to, whether attachments exist or not)
  • the full message is cached (ie as above plus full body text, and exact attachment names)
  Which to use will depend upon the use case. Getting the full message takes about 6 times as long as getting just the header, depending on message length. It is recommended to use header Caching (1)    
  Pass this an account. This will load into the cache all emails that it does not already have. Currently it will do a maximum of 100 emails. So, if there are more than 100 new emails (or first time on large accounts), it will have to be called multiple times. It returns back 'newrows' - a count of the emails loaded, and 'notes' - which is mostly for debugging.    
  You can pass 'fullrefresh=1' to force it to clear the cache and start again. This could be used for debugging, or to handle when people use multiple tools to handle emails.    
  As a note, if it has trouble lining up what it knows about, and the server contents (eg someone has deleted messages externally), it will do the equivalent of 'fullrefresh=1'. This means any survey information you might have stored against the row will be lost.    
  An advanced search. If you are caching headers only, The 'body' field will have the text 'Not cached', 'Attachments' will be Y/N If you are caching body, Attachments will still have Y/N, but AttachmentCount, and AttachmentList will have values too. DetailsCached Y/N indicates whether the full body / attachments have been retrieved (see MESSAGING_EMAIL_CACHE_GET_DETAILS below)    
  Use this to delete an email (via the standard remove=1), or to update the flags (by passing flags='....'). Currently, it blocks the /DELETED flag - use remove=1 instead    
  If you are caching headers only, use this to populate the rest on an email. It will set body, and the attachment fields    
  An advanced search. This relies on the message details having been downloaded.    
  Pass the id from the attachment search above