Hi Ben and Bridger,
I think you'd need to write a separate application or module to handle this, or use workarounds. Here are a few options you could explore:
1) Use the
Google API Client libraries to write an application in your preferred language that queries all messages and saves them in XML to use in a BaseX DB. I've used the PHP client library for Gmail, Drive, Groups, and Analytics reports, and it made the initial OAuth token setup relatively painless (as in, I was only tearing my hair out for a single day, not multiple).
2) Write a script in your preferred language that uses IMAP to fetch and save the messages.
PHP,
Java, and
Python
have built-in or third-party client libraries. But as Ben said, authentication will be a pain because Gmail
won't allow apps to authenticate with just usernames and passwords
anymore. You'd need to build in OAuth with your own methods.
3) Find an existing web client to sync to your Gmail, and find where it
stores local copies of the messages. Use them to create a BaseX DB. It
might be difficult or impossible to find one that saves messages in
neat, convenient XML files, though, so you might have to export an
archive and do some file processing processing every time you want to
perform a query.
-Tamara