Skip to content

Instantly share code, notes, and snippets.

@samirsaci
Created September 3, 2022 11:35
Show Gist options
  • Select an option

  • Save samirsaci/e5e8fb5394b353e12dc6e67f1f8e577c to your computer and use it in GitHub Desktop.

Select an option

Save samirsaci/e5e8fb5394b353e12dc6e67f1f8e577c to your computer and use it in GitHub Desktop.
Mail Report
# Open the visual
with open(file_img, 'rb') as fp:
img = MIMEImage(fp.read())
img.add_header('Content-Disposition', 'attachment', filename=file_img)
img.add_header('X-Attachment-Id', '0')
img.add_header('Content-ID', '<0>')
fp.close()
msg.attach(img)
# Open the header
with open(file_header, 'rb') as fp:
img = MIMEImage(fp.read())
img.add_header('Content-Disposition', 'attachment', filename=file_header)
img.add_header('X-Attachment-Id', '1')
img.add_header('Content-ID', '<1>')
fp.close()
msg.attach(img)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment