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
- TestCase helpers by pbx 6 years, 1 month ago
- Effective content caching for mass-load site using redirect feature by nnseva 1 year, 10 months ago
- Read more link by nny777 4 years, 10 months ago
- Increase maximum number of changelist items for "Show all" link to appear by ramen 3 years, 6 months ago
- Transparent encryption for model fields by shadfc 4 years, 10 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!
#