title: Extracting a body of an email using [Python 3.6]
body: <p>I have an inbox and I need to write a code that triggers every time a new message arrives, and extracts a body of that email. </p>
  
  <p>I have this code so far: </p>
  
  <pre><code>import poplib, email
  from email import parser
  
  pop_conn = poplib.POP3_SSL('pop.gmail.com')
  email_user = 'email@gmail.com'
  email_pass = 'password'
  
  pop_conn.user(email_user)
  pop_conn.pass_(email_pass)
  
  #Get messages from server:
  messages = [pop_conn.retr(i) for i in range(1, 
  len(pop_conn.list()[1]) + 1)]
  
  #Parse message intom an email object:
  messages = [parser.Parser().parsestr(mssg) for mssg in messages]
  for message in messages:
      print(message.get_payload(None, True))
  
  pop_conn.quit()
  </code></pre>
  
  <p>The error I am getting is: </p>
  
  <pre><code>---------------------------------------------------------------------------
  TypeError                                 Traceback (most recent call last)
  &lt;ipython-input-6-2a08d6a8ccf9&gt; in &lt;module&gt;()
    2 #Parse message intom an email object:
    3 #messages = [email.message_from_bytes(mssg) for mssg in messages]
  ----&gt; 4 messages = [parser.Parser().parsestr(mssg) for mssg in messages]
    5 for message in messages:
    6 #    print(message['body'])
  
  &lt;ipython-input-6-2a08d6a8ccf9&gt; in &lt;listcomp&gt;(.0)
    2 #Parse message intom an email object:
    3 #messages = [email.message_from_bytes(mssg) for mssg in messages]
  ----&gt; 4 messages = [parser.Parser().parsestr(mssg) for mssg in messages]
    5 for message in messages:
    6 #    print(message['body'])
  
  /Applications/anaconda3/lib/python3.6/email/parser.py in parsestr(self, text, headersonly)
   66         the file.
   67         """
  ---&gt; 68         return self.parse(StringIO(text), headersonly=headersonly)
   69 
   70 
  
  TypeError: initial_value must be str or None, not tuple
  
  TypeError: initial_value must be str or None, not tuple
  </code></pre>
  
  <p>Why am I getting a tuple? How do I extract a body from the messages[n]? </p>