- first_part = [self.msg.walk()][0]
- body = first_part.get_payload(decode=True)
- charset = first_part.get_content_charset(msg_charset)
- mime_type = first_part.get_content_type()
+ if msg.is_multipart():
+ for part in msg.walk():
+ mime_type = part.get_content_type()
+ if mime_type == 'text/plain':
+ break
+ body = part.get_payload(decode=True)
+ charset = part.get_content_charset(msg_charset)
+ else:
+ body = msg.get_payload(decode=True)
+ charset = msg_charset
+ mime_type = msg.get_content_type()