Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29758

Print body from an email imap python

$
0
0

I'm trying to print the email body of all the emails from an specific sender, when I run the code I when an output of lines of this 5H6ONzrsveoHzDAKli/ and more random letters and signs. Here is the whole code. Thankyou

import imaplib
import pprint

imap_host = 'imap.gmail.com'
imap_user = 'user@googlemail.com'
imap_pass = 'password'

# connect to host using SSL
imap = imaplib.IMAP4_SSL(imap_host)

## login to server
imap.login(imap_user, imap_pass)

imap.select('Inbox')

tmp, data = imap.search(None, '(FROM "specific@gmail.com")')
for num in data[0].split():
    tmp, data = imap.fetch(num, '(RFC822)')
    #print('Message: {0}\n'.format(num))
    pprint.pprint(data[0][1])

    break
imap.close()

Viewing all articles
Browse latest Browse all 29758

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>