Label Old Emails in Gmail
Organize your inbox by applying the right labels retroactively to your existing emails, perfect for cleaning up messy inboxes.
Last updated
October 1, 2025
Connectors used
Tags
Key Takeaways
- Retroactive labeling - Applies labels to your existing emails, not just new ones coming in.
- Manual trigger - You run this workflow when you are ready, rather than it running automatically.
- Uses your existing Gmail labels - The workflow reads your current labels and assigns them to old emails.
- Batch processing - Fetches and processes up to 100 emails per run.
What This Workflow Does
This workflow lets you organize old, unlabeled emails in Gmail by applying labels retroactively. You trigger it manually, and it fetches a batch of existing emails along with your Gmail labels, then applies the right labels to each message. It is designed for cleaning up a messy inbox, not for ongoing organization (use the "Label New Emails in Gmail" workflow for that).
Use cases:
- Cleaning up months or years of unlabeled emails in one go
- Organizing an inbox after switching to a label-based email management system
- Retroactively categorizing client or project emails that were never properly sorted
How It Works
| Step | What Happens |
|---|---|
| 1. Manual Trigger | You start the workflow manually when you are ready to organize. |
| 2. Find Emails | Fetches the last 100 emails from Gmail. |
| 3. Filter Emails | A code node removes unwanted senders from the batch. |
| 4. Flatten Results | A transform node flattens the email data for processing. |
| 5. List Labels | Retrieves all existing labels from your Gmail account. |
| 6. Extract Label Info | A code node formats label IDs and names into a clean list. |
| 7. Merge | Combines the filtered emails with the available labels. |
| 8. Attach Labels | A code node maps the full set of possible labels onto each email. |
| 9. Add Labels | Applies the appropriate labels to each email in Gmail. |
Workflow Nodes
| Node | Role |
|---|---|
| Manual Trigger | Starts the workflow on demand |
| Gmail Find Email | Queries Gmail for the last 100 emails |
| Code (Filter) | Filters out specific senders you want to exclude |
| Transform | Flattens nested email results into a single list |
| Gmail List Labels | Fetches all available Gmail labels |
| Code (Extract Labels) | Extracts label IDs and names into a structured format |
| Merge | Combines email data with label data |
| Code (Attach Labels) | Adds the full list of possible labels to each email object |
| Gmail Add Label to Email | Applies the chosen labels to each email |
Setup Instructions
- Add the "Label Old Emails in Gmail" template to your Needle workspace.
- Connect your Gmail account by creating a Gmail connector in Needle.
- Select your Gmail connector in the Find Email, List Labels, and Add Label to Email nodes.
- Optionally, update the filter code node to exclude specific senders.
- Click the manual trigger to run the workflow.
Customization
| What You Can Change | How |
|---|---|
| Sender filtering | Edit the code node to change which senders are excluded from labeling |
| Number of emails fetched | Change the maxResults value in the Find Email node (default is 100) |
| Label assignment logic | Update the instructions in the Add Label to Email node to adjust how labels are chosen |
| Email query | Modify the Find Email node's instructions to target a specific date range or search query |
FAQ
Q: How many emails can this process at once? A: The default configuration fetches 100 emails per run. You can adjust this in the Find Email node, but keep Gmail API limits in mind.
Q: Will this workflow run again automatically? A: No. It uses a manual trigger, so you need to start it each time. If you want ongoing labeling, use the "Label New Emails in Gmail" workflow instead.
Q: Does it overwrite existing labels? A: No. The workflow adds labels to emails. It does not remove any labels that are already applied.
Q: Can I run this multiple times? A: Yes. You can run it as many times as you want to process different batches of emails.
Want to showcase your own workflows?
Become a Needle workflow partner and turn your expertise into recurring revenue.