Bundle Slip Mail Automator is a Python script designed to automate the process of fetching emails from a specific email account, extracting attachments, sorting and arranging them, and saving them into a designated folder.
- Fetches emails from a specified email account using the Gmail API.
- Extracts attachments (such as PDFs, images, and Excel files) from the emails.
- Performs various operations on the attachments, including:
- Cropping images to the desired size.
- Converting images to PDF format.
- Merging multiple PDF files into a single file.
- (Optionally) Merging multiple Excel files into a single file.
- Moves processed files to respective folders for better organization.
- Provides an additional function to extract email addresses from
.eml
files and store them in a JSON file.
Before running the script, make sure you have the following prerequisites:
- Python 3.x installed on your system.
- A Google account with Gmail enabled.
- A
credentials.json
file obtained from the Google Cloud Console (instructions provided in the project files).
-
Clone the repository or download the source code:
git clone https://github.com/abhi245y/bundle-slip-mail-automator.git
-
Navigate to the project directory:
cd bundle-slip-mail-automator
-
Run the
install_requirements.sh
script to install the required Python packages:./install_requirements.sh
-
Obtain the
credentials.json
file from the Google Cloud Console by following these steps:- Go to the Google Cloud Console.
- Create a new project or select an existing one.
- Enable the Gmail API for your project.
- Create credentials (an OAuth client ID) for a desktop application.
- Download the
credentials.json
file and place it in the project directory.
-
(Optional) If your college/organization email addresses are not included in the
config/college_emails.json
file, you can update it manually or use theextraFunction()
inmain.py
to extract email addresses from.eml
files and store them in the JSON file.
-
Run the
runScript.sh
script to start the script:./runScript.sh
-
The script will prompt you to log in to your Google account if necessary.
-
After successful authentication, the script will fetch emails from the specified account, process the attachments, and save the output files in the designated folders.
bundle-slip-mail-automator/
├── config/
│ └── college_emails.json
├── EZGmail.py
├── install_requirements.sh
├── main.py
├── runScript.sh
├── runScript.bat
└── README.md
main.py
: The main Python script that contains the core functionality.EZGmail.py
: A Python module used to interact with the Gmail API (created by Al Sweigart).config/college_emails.json
: A JSON file containing the list of college/organization email addresses used for filtering emails.install_requirements.sh
: A bash script to install the required Python packages.runScript.sh
: A bash script to run themain.py
script.README.md
: This file, providing instructions and documentation for the project.
Contributions to this project are welcome. If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.
This project is licensed under the MIT License.
- The
EZGmail.py
module was created by Al Sweigart (al@inventwithpython.com). - The project utilizes various Python libraries, including
ezgmail
,img2pdf
,PyPDF2
,imutils
,cv2
, andpandas
.