imaplib

How to understand the equal sign '=' symbol in IMAP email text?

耗尽温柔 提交于 2019-11-27 23:29:51
I am currently using Python imaplib to process email text. I use fetch command to fetch the raw data email from GMail server. However, I found one thing really tricky - the equal sign '='. It is not a normal equal sign but a special symbol. For example: '=' sometimes acts as the hyphenation mark at the end of text line: Depending upon your module selections, course lecturers may also contact yo= u with preparatory work over the next few weeks. It would be wise to start = reviewing the preparatory reading lists provided on the module syllabi now = Sometimes, it acts as a escape mark similar to

python imaplib to get gmail inbox subjects titles and sender name

喜夏-厌秋 提交于 2019-11-27 09:47:43
问题 I'm using pythons imaplib to connect to my gmail account. I want to retrieve the top 15 messages (unread or read, it doesn't matter) and display just the subjects and sender name (or address) but don't know how to display the contents of the inbox. Here is my code so far (successful connection) import imaplib mail = imaplib.IMAP4_SSL('imap.gmail.com') mail.login('mygmail@gmail.com', 'somecrazypassword') mail.list() mail.select('inbox') #need to add some stuff in here mail.logout() I believe

'str' object has no attribute 'decode'. Python 3 error?

我只是一个虾纸丫 提交于 2019-11-27 02:58:55
Here is my code: import imaplib from email.parser import HeaderParser conn = imaplib.IMAP4_SSL('imap.gmail.com') conn.login('example@gmail.com', 'password') conn.select() conn.search(None, 'ALL') data = conn.fetch('1', '(BODY[HEADER])') header_data = data[1][0][1].decode('utf-8') at this point I get the error message AttributeError: 'str' object has no attribute 'decode' Python 3 doesn't have decode anymore, am I right? how can I fix this? Also, in: data = conn.fetch('1', '(BODY[HEADER])') I am selecting only the 1st email. How do I select all? You are trying to decode an object that is

Fetch an email with imaplib but do not mark it as SEEN

谁说胖子不能爱 提交于 2019-11-26 22:23:05
I want to parse some emails from a user 's inbox but when I do: typ, msg_data = imap_conn.fetch(uid, '(RFC822)') It marks the email as SEEN or read. This is not the desired functionality. Do you know how can I keep the email at its previous stare either SEEN or NOT SEEN? lezardo You might also set read_only to true when selecting the folder: imap_conn.select('Inbox', readonly=True) The following should work: typ, msg_data = imap_conn.fetch(uid, '(BODY.PEEK[HEADER])') or BODY.PEEK[TEXT] , etc. You can use (RFC822.PEEK) as the "message-parts" argument, according to RFC 1730 (I have not verified

How to fetch an email body using imaplib in python?

China☆狼群 提交于 2019-11-26 21:59:33
I'd like to fetch the whole message from IMAP4 server. In python docs if found this bit of code that works: >>> t, data = M.fetch('1', '(RFC822)') >>> body = data[0][1] I'm wondering if I can always trust that data[0][1] returns the body of the message. When I've run 'RFC822.SIZE' I've got just a string instead of a tuple. I've skimmed through rfc1730 but I wasn't able to figure out the proper response structure for the 'RFC822'. It is also hard to tell the fetch result structure from imaplib documentation. Here is what I'm getting when fetching RFC822 : ('OK', [('1 (RFC822 {858569}', 'body of

How to understand the equal sign '=' symbol in IMAP email text?

筅森魡賤 提交于 2019-11-26 21:29:02
问题 I am currently using Python imaplib to process email text. I use fetch command to fetch the raw data email from GMail server. However, I found one thing really tricky - the equal sign '='. It is not a normal equal sign but a special symbol. For example: '=' sometimes acts as the hyphenation mark at the end of text line: Depending upon your module selections, course lecturers may also contact yo= u with preparatory work over the next few weeks. It would be wise to start = reviewing the

'str' object has no attribute 'decode'. Python 3 error?

廉价感情. 提交于 2019-11-26 10:18:48
问题 Here is my code: import imaplib from email.parser import HeaderParser conn = imaplib.IMAP4_SSL(\'imap.gmail.com\') conn.login(\'example@gmail.com\', \'password\') conn.select() conn.search(None, \'ALL\') data = conn.fetch(\'1\', \'(BODY[HEADER])\') header_data = data[1][0][1].decode(\'utf-8\') at this point I get the error message AttributeError: \'str\' object has no attribute \'decode\' Python 3 doesn\'t have decode anymore, am I right? how can I fix this? Also, in: data = conn.fetch(\'1\',

How to fetch an email body using imaplib in python?

China☆狼群 提交于 2019-11-26 07:26:53
问题 I\'d like to fetch the whole message from IMAP4 server. In python docs if found this bit of code that works: >>> t, data = M.fetch(\'1\', \'(RFC822)\') >>> body = data[0][1] I\'m wondering if I can always trust that data[0][1] returns the body of the message. When I\'ve run \'RFC822.SIZE\' I\'ve got just a string instead of a tuple. I\'ve skimmed through rfc1730 but I wasn\'t able to figure out the proper response structure for the \'RFC822\'. It is also hard to tell the fetch result