Retrieve Gmail Inbox Emails Programmatically
Shared on August 26, 2025
JavaScriptNode.js
“
Get the 10 most recent emails from my Gmail inbox (exclude Spam/Trash), capturing date, sender name, sender email, subject, and a short snippet/body preview, then save the results to a CSV file.
“
Sample Output
Example output generated from this coding session
gmail_emails.csv
2.64 KB • text/csv
date | senderName | senderEmail | subject | snippet |
---|---|---|---|---|
6:02 AM | Positive Grid | updates@mail.positivegrid.com | Unlock Pro Tone. No Pedals Needed. | - Skip the pedals and unlock killer tone straight from your amp. ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏... |
3:40 AM | Reddit | noreply@redditmail.com | Next ECommerce | - r/nextjs: Next ECommerce Hey Everyone, I'm currently learning how to set up an Ecommerce using next.js and it's overwhelming for a junior/noobie ind... |
9:33 PM | Hinge Team | hello@mail.hinge.co | Learn More About Hinge’s Updated Terms of Use | - Learn More About Hinge's Updated Terms of Use We wanted to let you know that as of today we've made some changes to the Hinge's Terms of Use. These ... |
9:32 PM | GitHub | noreply@github.com | [GitHub] Your Dependabot alerts for the week of Aug 19 - Aug 26 | - Explore this week on GitHub GitHub security alert digest adcentury's repository security updates from the week of Aug 19 - Aug 26 adcentury's person... |
7:33 PM | LinkedIn News | editors-noreply@linkedin.com | Workers are clocking out earlier | - Everyone's leaving work early now — but there are still big differences between the East and West coasts. ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ... |
Aug 25 | Epic Pass | SeasonPass@epicpassmail.com | Lowest Price of Fall Ends 9/1! | - Go ahead and put winter on your calendar. ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ... |
Aug 25 | NARS Cosmetics | nars@email.narscosmetics.com | Try on The NEW Multiple. (Virtually.) | - Choose from 12 shades to find yours. ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏... |
Aug 25 | Amanda Natividad | marketing@sparktoro.com | Tomorrow: The talk I’ll only give once | - Hi friend, At SparkTogether, every talk is a career story you've never heard before — and probably never will again. No recordings, and we ask atten... |
Aug 25 | Costco Wholesale | Costco@digital.costco.com | Shop NEW Savings In-Warehouse and Online! | - TVs, appliances, household essentials and more. View in browser. Costco.com Starts Today, 8/25/25! Member Only Savings in Warehouse and online Membe... |
Aug 25 | AI Breakfast | aibreakfast@mail.beehiiv.com | Meta Partners with Midjourney | - August 25, 2025 | Read Online Meta Partners with Midjourney In partnership with Good morning. It's Monday, August 25th. On this day in tech history:... |
Conversation
2 messages
Frequently Asked Questions
Key insights from this conversation
What was the goal of this conversation?
Automate retrieving the 10 most recent Gmail messages (excluding Spam/Trash) and save date, sender name/email, subject, and snippet to CSV.
What was accomplished?
Built a Playwright script to extract the requested fields for 10 emails and save to /home/user/project/output/gmail_emails.csv.
What tools/technologies were used?
Playwright for browser automation, Node.js/JavaScript, and existing utils.js in the project.
What are the notable outcomes or reuse tips?
CSV is ready to open in any app; uses existing utilities for easy reuse and extension.