wasm-demo/demo/ermis-f/imap-protocol/cur/1600094983.22563.mbox:2,S

38 lines
1.7 KiB
Plaintext

MBOX-Line: From comicpilsen at gmail.com Wed Dec 28 04:36:42 2016
To: imap-protocol@u.washington.edu
From: comicpilsen <comicpilsen@gmail.com>
Date: Fri Jun 8 12:34:55 2018
Subject: [Imap-protocol] is IMAP still the protocol to use to read emails???
Message-ID: <7b8b6e00-3396-2c08-f58e-290d619214ea@gmail.com>
I am a little confused. I code in Python ( 3.5.1) and I am "trying" to read the body of
messages from a gmail account. The issue is that I see a lot of POP3 activity on stack
exchange and google but very little for IMAP. So is IMAP dead? If so what should I be
looking at?
All I want to do is read in my email body and do something with it. I really am having
issues like the one below.
Using python 3.5.1 and its throwing this trace
|TypeError:initial_value must be str orNone,notbytes|
on the line
|text_msg =email.message_from_string(data[0][1])|
I know the text of the message is stashed in data[0][1] but can't seem to find the correct
code to convert from bytes to string for the RFC822 in python 3.5.1 what is the line
please? here is the code I found to read my IMAP box which works well for getting the
messages, formatting the date and showing the subject.
|rv,data =M.fetch(num,'(RFC822)')ifrv !='OK':print("ERROR getting message",num)returnmsg
=email.message_from_bytes(data[0][1])text_msg
=email.message_from_string(data[0][1])hdr=mail.header.make_header(email.header.decode_header(msg['Subject']))subject
=str(hdr)print('Message %s: %s'%(num,subject))print("text = ",text_msg)|
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman13.u.washington.edu/pipermail/imap-protocol/attachments/20161228/83f781fd/attachment.html>