Skip to content

swinton/gmail-repl

Repository files navigation

🔁 gmail-repl

A REPL for GMail

Setup

Follow the Node.js quickstart from the Gmail for Developers guide, and make sure your desktop application credentials are stored in a credentials.json file -- see credentials-example.json for an example.

Usage

./repl.js

Examples

Get profile

users.getProfile

await profile()

List messages

users.messages.list

// List all messages
await messages()

// List all from <email>
await messages('from:[email protected]')

// List unread from <email> sent after <date>
await messages('from:[email protected] is:unread after:2023/05/19')

Read a message

users.messages.get

await message('1883a5111e8ef47c')

List threads

users.threads.list

// List all threads
await threads()

// List all from <email>
await threads('from:[email protected]')

// List unread from <email> sent after <date>
await threads('from:[email protected] is:unread after:2023/05/19')

Read a thread

users.threads.get

await thread('1883b361aaef86b6')

Batch delete

users.messages.batchDelete

Batch delete unimportant promotional messages

await batchDeleteMessages('category:promotions -is:important -is:starred')

Batch delete messages from before 2021

await batchDeleteMessages('before:2021/01/01')