Anyquery is a query engine that allows you to run SQL queries on pretty much anything. In this guide, we will connect Anyquery to the Gmail IMAP server and query your emails using SQL.
Prerequisites
Before starting, ensure you have the following:
- A working installation of Anyquery
- A Gmail account
- The IMAP plugin installed tutorial
Step 1: Create an application password
Go to https://myaccount.google.com/apppasswords and create an application password for Anyquery. Input the name you want and copy the generated password.
Step 2: Create a new profile for the IMAP plugin
First, let’s create a new profile for the IMAP plugin. Run the following command:
Fill in the following details:
- Host:
imap.gmail.com
- Port:
993
- Username: Your Gmail email
- Password: The application password you generated without the spaces
Step 3: Query your emails
Now that you have set up the profile, you can query your emails using SQL. Here is an example query to get the subject and the sender of the first 10 emails: