diff --git a/send_mail_report.py b/send_mail_report.py
index ed739c1..21a5ac5 100644
--- a/send_mail_report.py
+++ b/send_mail_report.py
@@ -12,13 +12,7 @@
# Prepare the HTML content
current_timestamp = datetime.now().strftime('%Y-%m-%d')
subject = 'IMMUNIZE: OCI Images Patching Report'
-html_body = f'
Patched Images 💉 {current_timestamp}
'
-html_body += 'check the full catalog 📚 here !'
-html_body += '
'
-html_body += 'Stay Safe! 💪
'
+html_body = f'Patched Images 💉 {current_timestamp}
'
# Get email and password from GitHub secrets
email_address = os.environ.get('EMAIL_ADDRESS', '')
@@ -32,16 +26,27 @@
message['From'] = email_address
message['To'] = ', '.join(recipients)
message['Subject'] = subject
+
+# Get all directories with the name "*-openvex-report" in root of the project folder
+report_directories = [dirname for dirname in os.listdir(script_directory) if os.path.isdir(os.path.join(script_directory, dirname)) and dirname.endswith("-openvex-report")]
+
+# Iterate through report directories
+for report_dir in report_directories:
+ report_dir_path = os.path.join(script_directory, report_dir)
+ # Get all files in the report directory
+ report_files = [filename for filename in os.listdir(report_dir_path) if os.path.isfile(os.path.join(report_dir_path, filename))]
+ # Attach reports to the email
+ for report_file in report_files:
+ with open(os.path.join(report_dir_path, report_file), 'rb') as file:
+ part = MIMEApplication(file.read(), Name=os.path.basename(report_file))
+ part['Content-Disposition'] = f'attachment; filename="{report_file}"'
+ message.attach(part)
+
+html_body += '
'
+html_body += 'check the full catalog 📚 here !'
+html_body += '
'
+html_body += 'Stay Safe! 💪
'
message.attach(MIMEText(html_body, 'html'))
-# Get all files named "*-openvex-report" in root of the project folder
-report_files = [filename for filename in os.listdir(script_directory) if filename.endswith("-openvex-report")]
-# Attach reports to the email
-for report_file in report_files:
- html_body += f'{report_file}'
- with open(os.path.join(script_directory, report_file), 'rb') as file:
- part = MIMEApplication(file.read(), Name=os.path.basename(report_file))
- part['Content-Disposition'] = f'attachment; filename="{report_file}"'
- message.attach(part)
# Connect to the GMAIL SMTP server and send the emails
with smtplib.SMTP('smtp.gmail.com', 587) as server: