I have this code (below) that shows me all emails in my email account. It also shows the whole email, including all the metadata (which I dont want). Is there a way to just print the To, From, Subject and Message only? This is in Python as well. Thanks.

Code:

```
import getpass, imaplib
import os

email = raw_input('Email: ')
password = getpass.getpass()
M = imaplib.IMAP4_SSL("imap.gmail.com", 993)
print('Logging in as ' + email + '...')
M.login(email, password)
M.select()
typ, data = M.search(None, 'ALL')
for num in data[0].split():
    typ, data = M.fetch(num, '(RFC822)')
    print ('Message %s\n%s\n' % (num, data[0][1]))
M.close()
M.logout()

```