def get_decoded_attachments(self, django_message):
msg_bytes = django_message.message().as_bytes()<EOL>email_message = message_from_bytes(msg_bytes)<EOL>def iter_attachments():<EOL><INDENT>for i in email_message.walk():<EOL><INDENT>if i.get_content_disposition() == '<STR_LIT>':<EOL><INDENT>filename = i.get_filename()<EOL>content = i.get_payload(decode=True)<EOL>mimetype = i.get_content_type()<EOL>yield filename, content, mimetype<EOL><DEDENT><DEDENT><DEDENT>return list(iter_attachments())<EOL>
Encode the specified django.core.mail.message.EmailMessage, then decode
it using Python's email.parser module and, for each attachment of the
message, return a list of tuples with (filename, content, mimetype).