Use this advanced n8n workflow to poll multiple Gmail accounts hourly, normalize incoming messages, store unified email data in n8n Data Tables, and send immediate Discord alerts for new activity.
Download this n8n workflow template and start using it instantly.
Agencies managing communications across multiple client or burner accounts.
Developers requiring unified logging and monitoring for many email inboxes.
Anyone needing an advanced example of using the n8n node for dynamic credential management.
Users looking for high-utility n8n templates involving Gmail automation and structured data storage.
Managing new messages across numerous Gmail accounts can be highly complex and often requires manual credential switching. This n8n workflow solves this by utilizing n8n Data Tables to store account credentials and state data (like last_polled).
Starting with an n8n trigger, the automation iterates through every account, dynamically injecting the necessary Gmail OAuth2 credentials using the powerful Run Node With Credentials n8n node. It fetches only new emails since the last successful poll, normalizes the raw message payload, and saves a standardized version into a master Data Table, preventing duplicates and establishing a single source of truth.
This architecture ensures that even complex, multi-credential tasks are handled seamlessly within a single n8n workflow, providing efficient polling and a summary notification via Discord upon completion.
This highly advanced n8n workflow operates in a structured, looping fashion:
lastpolled timestamp, from the coldemailaccounts n8n Data Table.lastpolled time and the current time ($now) into Epoch seconds, defining the after: and before: search filters for Gmail.getAll operation using the calculated time window, ensuring only new, relevant emails are fetched.Email Normalization) that transforms the complex Gmail API response into a clean, standardized JSON object. This data is then upserted (inserted or updated) into the central All Emails n8n Data Table using the message ID to guarantee deduplication. Finally, the account's lastpolled timestamp in the source Data Table is updated.lastpolled timestamp for that account, marking the successful completion of the poll cycle.To set up this n8n workflow, follow these steps:
coldemailaccounts: This table must store rows for each account, including columns like credid (the ID of the corresponding Gmail OAuth2 credential), email, and lastpolled (a Date/Time field).All Emails: This table is the unified data sink where normalized emails will be stored. Ensure it has columns matching the standardized output (e.g., messageid, emaildata). Schedule Trigger (n8n trigger): The starting point. Configured to run periodically (e.g., every hour) to maintain continuous email polling.
Get All Email Accounts (Data Table n8n node): Reads all rows from the coldemailaccounts Data Table, providing the necessary credentials and state data for the loop.
Loop Over Items (Split In Batches n8n node): Ensures that the subsequent logic is executed sequentially for each email account defined in the Data Table.
Code in JavaScript (Code n8n node): Calculates the exact polling window (after and before timestamps) using the lastpolled value of the current item.
Run Node With Credentials X (Custom n8n node): This specialized n8n node dynamically loads the Gmail OAuth2 credential ID stored in the current Data Table item and executes an internal Gmail n8n node to fetch messages, making the n8n workflow highly scalable.
Email Normalization (Code n8n node): A critical custom scripting step that standardizes the raw data received from the Gmail n8n node (parsing headers, extracting body text/HTML, and listing attachments) into a clean, unified JSON structure.
upsert emails (Data Table n8n node): Writes the normalized email data to the All Emails master table. It uses the upsert operation and matches on messageid to prevent the insertion of duplicate emails.
Update lastpolled / Update lastpolled1 (Data Table n8n node): These n8n nodes ensure that the coldemailaccounts table is updated with the current timestamp, maintaining accurate state management for the next scheduled n8n trigger run.
Use this n8n workflow to automate plant care reminders using Google Sheets for scheduling, OpenWeather for smart rain delay checks, and Telegram notifications with click-to-confirm buttons.

Use this powerful n8n workflow to generate dynamic travel itineraries. Integrates Google Gemini (Vertex AI), live flight searches, and custom logic via n8n templates.

Build a robust n8n workflow to place subjects into iconic locations using the Replicate AI model. This n8n template features automated polling, robust error handling, and structured JSON output for production use.

Use this powerful n8n workflow to poll unread emails from JMAP compliant providers like Fastmail. Learn how to construct complex JMAP queries using the n8n HTTP Request node.








































