Skip to content

Gmail Email Extractor πŸ“§ – A Python automation script that uses the Gmail API to fetch emails from categories (Primary, Social, Promotions, Drafts) and export them into well-formatted Excel files with OAuth 2.0 authentication.

License

Notifications You must be signed in to change notification settings

shoaibatmaca/Mail-Extractor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Gmail Email Extractor πŸ“§

A Python automation script that connects to your Gmail account via the official Gmail API, fetches emails from different categories (Primary, Social, Promotions, Drafts, etc.), and saves them into separate Excel (.xlsx) files.


✨ Features

  • OAuth 2.0 authentication (Google API)
  • Fetches emails from Gmail by category:
    • Primary
    • Social
    • Promotions
    • Drafts
  • Saves each category into separate Excel files
  • Properly formatted Excel output (Date, Sender, Subject, Snippet)
  • Handles empty/null values gracefully

πŸ›  Requirements

  • Python 3.8+
  • A Google Cloud project with Gmail API enabled
  • Installed dependencies:
pip install google-api-python-client google-auth-httplib2 google-auth-oauthlib openpyxl

πŸš€ How to Use

Enable Gmail API in Google Cloud: Go to: https://console.cloud.google.com/ Create a new project Enable the Gmail API Create OAuth client credentials Download credentials.json Place the credentials file in your project folder.

Run the script for the first time:

python main.py

A browser window will open to authenticate your Google account. This will generate a token.json file for future runs. Check the output Excel files will be saved in the current directory: primary_emails.xlsx social_emails.xlsx promotions_emails.xlsx draft_emails.xlsx


πŸ“œ License

MIT License – Free to use and modify.

🀝 Contributing

Pull requests are welcome. For major changes, open an issue first to discuss what you'd like to change.


πŸ’‘ Author

Muhammad Shoaib – Backend Developer (Django, Python)

About

Gmail Email Extractor πŸ“§ – A Python automation script that uses the Gmail API to fetch emails from categories (Primary, Social, Promotions, Drafts) and export them into well-formatted Excel files with OAuth 2.0 authentication.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages