Sending emails with HTML content and PDF attachment
To split multi-pages pdf into individual page and send each pdf to respective recipients from excel listing.
The program is able to split pdf file into individual file by page and send the file to recipients by email based on the excel listing.
Basically, the first page in pdf will send to first row recipient in the excel file. Files in the data folder is the sample pdf file and excel listing.
High level plan
- Split the pdf source into individual file by page.
- Get the excel listing.
- Send the email to recipients based on the logic.
Python Packages Used
- os – to get environment variables email address & password, and the path of file location
- pandas – to work with excel data
- PyPDF2 – to split pdf by page, to get page number
- smtplib – to connect to gmail server
- email – to make the email parameter and content more neatly
- Amend the following input to meet your needs:
- Input your original pdf file that needed to split
- Input the location to store the individual file
- Input the excel listing location that consists of recipients’ email address
- Input the email address and password (This information should store in environment variables)
- Amend the email content
- Once set, you can run the .py file.
- Email with pdf attachment will be send out.
- Send the email with multiple attachment at once if the email address is the same.