Hi Kindly need help to be able attaching a logo and a pdf when emailing, I have been following this great articles 1 and 2 but it seems am always getting something wrong.
-- Here is a sample code of mine , It fails the following error "<email.mime.image.MIMEImage instance at 0x7f7156a88d88> is not JSON serializable"
connection = mail.get_connection()
msg = EmailMultiAlternatives( subject, from_email, receiver)
msg.attach_alternative(mail_body, 'text/html') image = MIMEImage(insurer.company_logo.read()) image.add_header('Content-ID', '<{}>'.format('logo.png'))
msg.attach('logo.png',image, 'image/png') msg.send() connection.send_messages([msg])You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/422ff42f-6d18-4d4b-8fd6-0bef2a40c15d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment