This project aims to automate various tasks related to Gmail using the Gmail API. It provides functionalities to manage labels, retrieve emails based on specific queries, and apply labels to them.
- Python 3.x
- Libraries:
- google-auth-oauthlib
- google-auth-httplib2
- google-api-python-client
-
Clone the repository:
git clone https://github.com/yourusername/gmail-automation.git
-
Set up Google API credentials:
- Create a project in the Google Developer Console.
- Enable the Gmail API for the project.
- Create credentials (OAuth 2.0 client ID) and download the
credentials.json
file. Place it in the project directory.
-
Install dependencies:
pip install google-auth-oauthlib google-auth-httplib2 google-api-python-client
- Run the
quickstart.py
file to start the Gmail automation. This file demonstrates basic functionalities such as retrieving emails and applying labels.
- The
user.py
file contains auser
class that helps in managing labels. - The
find_labelid
method retrieves the label ID for a given label name.
- The
label.py
file defines alabel
class that represents a Gmail label. - The
createLabel
method creates a new label with the specified color and name.
- The
generateLabels
function inquickstart.py
generates labels for common senders based on a specified query. It retrieves emails and creates labels for them.
- Modify the
SCOPES
variable inquickstart.py
to request additional permissions as needed.
Contributions are welcome! Feel free to submit pull requests for new features, bug fixes, or enhancements.
This project is licensed under the MIT License - see the LICENSE file for details.