1 2 3 4 5 6 7 8 9 10 | from email.MIMEImage import MIMEImage
def email_embed_image(email, img_content_id, img_data):
"""
email is a django.core.mail.EmailMessage object
"""
img = MIMEImage(img_data)
img.add_header('Content-ID', '<%s>' % img_content_id)
img.add_header('Content-Disposition', 'inline')
email.attach(img)
|
More like this
- "Youtube watch link to embed" custom tag. by I159 4 months, 2 weeks ago
- youtubize template tag by TheJester 4 years, 9 months ago
- Simple "html email with images" sender by andres_torres_marroquin 11 months, 2 weeks ago
- Simple e-mail template tag by dchandek 3 years, 9 months ago
- hide emails with PIL - template filter by dekomote 2 years, 3 months ago
Comments
Example usage: from django.core.mail import EmailMessage from myproject import email_embed_image
#
This is exactly what I needed, thank you!
#