如何使用Python 3阅读电子邮件

如何使用Python 3阅读电子邮件,第1张

如何使用Python 3阅读电子邮件
import emailraw_email = data[0][1]email_message = email.message_from_string(raw_email)print email_message['To']print email.utils.parseaddr(email_message['From']) # for parsing "Yuji Tomita" <yuji@grovemade.com>print email_message.items() # print all headersdef get_first_text_block(self, email_message_instance):maintype = email_message_instance.get_content_maintype()if maintype == 'multipart':    for part in email_message_instance.get_payload():        if part.get_content_maintype() == 'text': return part.get_payload()elif maintype == 'text':    return email_message_instance.get_payload()

**我没有写这个取自https://yuji.wordpress.com/2011/06/22/python-imaplib-imap-example-
with-gmail/



欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5649496.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存