This Python script is designed to perform the following tasks:
- Extract Data from CSV: Reads a CSV file containing 'Name' and 'Email' columns and extracts the data.
- Attachment Handling: Searches for corresponding PDF files in a specified directory based on the 'Name' column extracted from the CSV.
- Email Sending: Sends an email to each recipient, attaching the relevant PDF file if found.
- Python 3.x
- Libraries:
csv
,smtplib
,email
,glob
- CSV File: Prepare a CSV file containing 'Name' and 'Email' columns.
- PDF Directory: Specify the path to the directory containing the PDF files.
-
File Configuration:
- Replace
file_path
variable with the path to your CSV file in theemailListname.csv
. - Replace
pdf_directory
variable with the path to the directory containing the PDF files. - Update the sender's email address and password.
- Replace
-
Run Script: Execute the Python script in your preferred environment.
- The script attempts to find a PDF file for each 'Name' in the specified directory. If found, it sends an email with the attached PDF; otherwise, it prints a notification about the missing PDF for a particular name.
- Ensure the proper configuration of sender's email and its authorization to send emails programmatically.
python email_pdf_sender.py