email - Extract attachements using mailbox python? -
i wanted extract email attachments mbox using mailbox library in python.
i've used following code extract from, to, subject, date, body
import mailbox mbox = mailbox.mbox('/tmp/personal folders/inbox/mbox') message in mbox: print message['subject'] print message['to'] print message['from'] print message['date']
how find , extract attachments in every mails? need include more library ?
use get_payload()
method (https://docs.python.org/2/library/email.message.html#email.message.message.get_payload).
return current payload, list of message objects when is_multipart() true, or string when is_multipart() false.
ex:
print message.get_payload()
Comments
Post a Comment