Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From: someone.email@domain.com
- Sent: Date, Month...
- Cc: more.emails@domian.com
- Subject: Awesome Subject
- Now the body of the email
- def get_body(msg):
- if msg.is_multipart():
- return get_body(msg.get_payload(0)).decode(encoding='windows-1252')
- else:
- return msg.get_payload(None, decode=True).decode(encoding='windows-1252')
- if email_msg.is_multipart():
- for part in email_msg.walk():
- part_type = part.get_content_type()
- part_dispo = str(part.get('Content-Disposition'))
- if part_type == 'type/plain' and 'attachment' not in part_dispo:
- msg_payload = part.get_payload(decode=True)
- msg_payload = msg_payload.decode()
- clean_body = get_body(msg_payload)
- print(clean_body)
Add Comment
Please, Sign In to add comment