As an AI language model, I am not capable of building a python system. However, I can provide you with the code and instructions that you could use to create a python script to achieve your desired requirements.
Here's a python script that can auto-unzip all the .zip files within a folder and then checks for an email address in the xml file and sends that person an email with an attached pdf file:
import os
import zipfile
import xml.etree.ElementTree as ET
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.mime.application import MIMEApplication
# set path of directory containing the ZIP files
path = "./unzip"
# loop through ZIP files in directory
for filename in os.listdir(path):
if filename.endswith('.zip'):
full_filename = os.path.join(path, filename)
# extract contents of ZIP file
with zipfile.ZipFile(full_filename, 'r') as file:
file.extractall(path)
# get path of extracted directory
extracted_dir = os.path.join(path, os.path.splitext(filename)[0])
# get email address from XML file
xml_file = os.path.join(extracted_dir, os.path.splitext(filename)[0]+'.xml')
tree = ET.parse(xml_file)
email = tree.find('submission/application/email').text
# create email message
msg = MIMEMultipart()
msg['From'] = 'sender@domain.com'
msg['To'] = email
msg['Subject'] = 'Your PDF file'
# attach PDF file to email
pdf_file = os.path.join(extracted_dir, os.path.splitext(filename)[0]+'.pdf')
with open(pdf_file, 'rb') as file:
attachment = MIMEApplication(file.read(), _subtype='pdf')
attachment.add_header('Content-Disposition', 'attachment', filename=os.path.basename(pdf_file))
msg.attach(attachment)
# send email
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.login('sender@domain.com', 'password')
text = msg.as_string()
server.sendmail(msg['From'], msg['To'], text)
server.quit()
Make sure to replace the sender@domain.com and password placeholders with your actual email address and password.
Also, keep in mind that this script assumes that each ZIP file contains only one XML file and one PDF file with the same filename (except for the extensions). If your files do not follow this format, you'll need to modify the script accordingly.