I used this to get all emails on inbox (on android shell or through tasker running a shell command):
sqlite3 /data/data/com.google.android.gm/databases/mailstore.YOUREMAIL@gmail.com.db "SELECT fromAddress || '@|@' || dateSentMs || '@|@' || Subject || '@|@' || snippet FROM messages m LEFT JOIN message_labels ml ON m.messageId = ml.message_messageId JOIN labels l ON l._id = ml.labels_id WHERE l.name = '^i' ORDER BY m.dateReceivedMs DESC;"
However, since I changed to a new device with android 7 (first emui 5.1 and then LineageOS 14.1), it doesn't work. Analyzing Gmail database with Sq lite dB reader, I found out that mailstore.YOUREMAIL@gmail.com.db file doesn't exist anymore. I checked the available db files but non of them seem to contain inbox info...
Does anybody now how to get inbox now?