我想通过imapclient模块获取腾讯QQ中的邮件。以下是我输入的代码:
import imapclient
imapObj = imapclient.IMAPClient('imap.qq.com',ssl=True)
imapObj.login('my_email_address@qq.com','MY_SECREST_PASSWORD')
imapObj.select_folder('INBOX',readonly=True)
UIDs = imapObj.search(['SINCE 05-Jul-2021'])
回应是:
UIDs
[46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 86, 87]
然后我输入以下代码:
rawMessages = imapObj.fetch([54],['BODY[]'])
import pprint
pprint.pprint(rawMessages)
但我得到了这个结果:
defaultdict(<class 'dict'>,
{54: {b'BODY[]': b'Received: from 69.72.42.10 (unknown [69.72.42.10'
b'])\r\n\tby newmx37.qq.com (NewMx) with SMTP id '
b'\r\n\tfor <651853891@qq.com>; Tue, 27 Jul 2021 '
b'17:17:25 +0800\r\nX-QQ-FEAT: Nrj7KsauvmTIWAx9l'
b'McI+hrdqGBrqmAk\r\nX-QQ-MAILINFO: NUNG9mg7s8ZO'
'''skip'''
b'p; &nbs=\r'
b'\np;=0D\r\n </div>=0D\r\n =0D\r\n=0D\r\n<'
b'/body></html>=\r\n\r\n----==_mimepart_60ffcf0651'
b'2b8_297158d1c343f9--\r\n\r\n',
b'FLAGS': (),
b'SEQ': 9}})
我应该如何获得正确的格式!