If you’re anything like me, your Gmail account tends to accumulate a lot of emails over time. While you can resort to exporting your data to free up some space, this process can be quite time-consuming, often stretching over hours or even days. However, with the advancements of 2023, you don’t need to possess advanced technical skills to efficiently retrieve the emails that matter most to you, saving them before embarking on a deleting spree!
I’m going to take the lazy route and see what chatGPT has to say…
The first few steps already presented a problem. The dev console doesn’t give you an option to download a JSON file so we’ll be taking another approach.
Step 1: Creating YAML File for Gmail Credentials:
Create a YAML file named credentials.yml in the same directory as your Python script.
Inside the YAML file, store your Gmail username and password.
Step 2: Installing Required Libraries:
Open your terminal or command prompt.
Run the following command to install the necessary libraries:
Step 3: Writing the Script
Create a new Python file, e.g., gmail_extractor.py.
Import the necessary libraries and read Gmail credentials from the credentials.yml file:
Step 4: Connect to your Gmail inbox using IMAP and search for emails using specific criteria (e.g., sender's email):
Step 5: Iterate through the emails, extract relevant details, and write them to a text file:
And you're done! Execute and save e-mails from the people you care about in minutes!
I posted my code on the next post....I don't have my github set up so if you're interested in the code, it's on the next post.
Posted on August 18, 2023 in coding by henryoviedo93 Tags: coding, python
Comments on 'Parsing with python' (0)
Comments Feed