Oct-07-2018, 10:52 AM
(This post was last modified: Oct-07-2018, 10:47 PM by Pedroski55.)
Well, solved it for my needs in the end.
It seems you cannot put a loop variable in 'server.fetch([loopVariable], ['BODY[]', 'FLAGS'])' I suppose that it is not translated then sent to the imap server, but sent directly.
Now I can print the email body content, I can save it to a text file. The rest does not involve email or internet, I can handle that.
It seems you cannot put a loop variable in 'server.fetch([loopVariable], ['BODY[]', 'FLAGS'])' I suppose that it is not translated then sent to the imap server, but sent directly.
Now I can print the email body content, I can save it to a text file. The rest does not involve email or internet, I can handle that.
import pyzmail import pprint from imapclient import IMAPClient server = IMAPClient('imap.qq.com', use_uid=True, ssl=True) server.login('[email protected]', 'myIMAPpassword') select_info = server.select_folder('Inbox') #server.search(['SINCE', '07-Oct-2018']) unseenMessages = server.search(['UNSEEN']) #rawMessage = server.fetch([57], ['BODY[]', 'FLAGS']) rawMessage = server.fetch(unseenMessages, ['BODY[]', 'FLAGS']) #print(rawMessage) #print(message.get_payload(1)) #message = pyzmail.PyzMessage.factory(rawMessage[57][b'BODY[]']) #message.text_part.get_payload().decode(message.text_part.charset) #print(message.get_payload()) for msgNum in unseenMessages: message = pyzmail.PyzMessage.factory(rawMessage[msgNum][b'BODY[]']) text = message.text_part.get_payload().decode(message.text_part.charset) print('Text' + str(msgNum) + ' = ') print(text)