Нужно распечатать вложения в виде таблицы в теле письма. Для отображения содержимого вложений в теле письма при отправке.
outer = MIMEMultipart()
outer['Subject'] = 'Pass/Fail Report'
outer['To'] = COMMASPACE.join(recipients)
outer['From'] = sender
outer.preamble = 'You will not see this in a MIME-aware mail reader.\n'
attachments =glob.glob('report*.csv')
# string to store the body of the mail
#body="Attaching reports"
body = "Attaching the report for the status of ingestion, for different Content Providers\n Content Providers:"+str(len(attachments))
# attach the body with the msg instance
outer.attach(MIMEText(body, 'html'))
# Add the attachments to the message
for file in attachments:
try:
with open(file, 'rb') as fp:
msg = MIMEBase('application', "octet-stream")
msg.set_payload(fp.read())
encoders.encode_base64(msg)
msg.add_header('Content-Disposition', 'attachment', filename=os.path.basename(file))
outer.attach(msg)
except:
print("Unable to open one of the attachments. Error: ", sys.exc_info()[0])
raise
composed = outer.as_string()