way to extract only the message from pop3

Tim Williams tim at tdw.net
Thu Apr 5 12:14:24 CEST 2007

On 3 Apr 2007 12:36:10 -0700, flit <superflit at gmail.com> wrote:
> Hello All,
> Using poplib in python I can extract only the headers using the .top,
> there is a way to extract only the message text without the headers?

for i in range( M.stat()[0] ): # M.stat returns msg-count and mbox size
    msg = '\r\n'.join( M.retr(i+1)[1] )    #  retrieve the email into string
    hdrs,body = msg.split('\r\n\r\n',1)    # split it into hdrs & body

HTH :)

More information about the Python-list mailing list