/Gmail-to-PDF-Converter

A python 3 project that retrieves emails from your google account, converts them to pdf, and saves them locally.

Primary LanguagePython

A python 3 project that converts emails to pdfs. This is dependent on Nick Russler's Email to PDF Converter. (The .jar file is already included in this repo)

Script Requirements:

  • Python 3 or above. Please tick the "add to PATH" option during installation. To check if you already have python installed or to verify the installation, type in python --version in your command line.
  • JRE 8 or above for the script to run the .eml to .pdf converter. To check if you already have a JRE installed or to verify the installation, type in java --version in your command line.
  • The Google Python API to connect with Google services.
  • wkhtmltopdf to write PDF files. Please add the /wkhtmltopdf/bin directory to your environment paths.
    1. To do this, just open your windows search bar, type in environment
    2. Press the Edit the system environment variables
    3. A prompt titled System Properties should appear, then click on Envionment Variables
    4. Under your user variables, look for the Path variable and double click on it
    5. Add the directory of your /wkhtmltopdf/bin folder

Instructions:
  1. After completing the requirements above, setup config.json. Please enlose all values in double quotation marks. For Windows PCs, please use double backslashes ("\\") for the directory addresses. Below are the following fields along with their meaning:
    • "label-name": The set label of the emails to be printed from your gmail account.
    • "from": The sender of the emails to be printed. Leave blank to ignore this filter.
    • "to": Ther receipient of the emails to be printed. Leave blank to ignore this filter
    • "get-mail-in-trash": If mails in trash with the matching label should also be processed. "True"/"False"
    • "user": The email address to be used. For default user, just put "me" as the value.
    • "dir-name": The parent directory url where the pdfs will be saved. "default" uses the working directory of convert.bat.
    • "save-folder": The folder where the files will be saved.
    • "jar-path": The absolute path of the emailconverter.jar. "default" uses the working directory of convert.bat and looks for /src/emailconverter.jar.
    • "start-date": Date in the format "yyyy/mm/dd". Use "default" to indicate no start date requirements.
    • "end-date": Date in the format "yyyy/mm/dd". Use "default" to indicate no end date requirements. Note: this is exclusive, meaning setting January 6 as the end date will only include mails that were sent upto January 5 11:59 PM.

  2. After setting the config, just double click the "convert.bat", and it will automatically run the script for you.

  3. If it is the first time running, google will ask you to sign in. Please sign in to your account that have the emails to be processed. A token.json will be created so that you will not have to log in the next time.

If there are any problems/suggested features, please contact me through jaredblase@gmail.com