def explore_message(c, uid):
 msgdict = c.fetch(uid, ['BODYSTRUCTURE', 'FLAGS'])
 while True:
  print
  print 'Flags:',
  flaglist = msgdict[uid]['FLAGS']
  if flaglist:
   print ' '.join(flaglist)
  else:
   print 'none'
  display_structure(msgdict[uid]['BODYSTRUCTURE'])
  print
  reply = raw_input(('Message %s - type a part name, or "q" to quit: ' % uid)).strip()
  print
  if reply.lower().startswith('q'):
   break
  key = ('BODY[%s]' % reply)
  try:
   msgdict2 = c.fetch(uid, [key])
  except c._imap.error:
   print ('Error - cannot fetch section %r' % reply)
  else:
   content = msgdict2[uid][key]
   if content:
    print banner
    print content.strip()
    print banner
   else:
    print '(No such section)'

def explore_message ( c , uid ) : msgdict = c . fetch ( uid , [ 'BODYSTRUCTURE' , 'FLAGS' ] ) while True : print print 'Flags:' , flaglist = msgdict [ uid ] [ 'FLAGS' ] if flaglist : print ' ' . join ( flaglist ) else : print 'none' display_structure ( msgdict [ uid ] [ 'BODYSTRUCTURE' ] ) print reply = raw_input ( ( 'Message %s - type a part name, or "q" to quit: ' % uid ) ) . strip ( ) print if reply . lower ( ) . startswith ( 'q' ) : break key = ( 'BODY[%s]' % reply ) try : msgdict2 = c . fetch ( uid , [ key ] ) except c . _imap . error : print ( 'Error - cannot fetch section %r' % reply ) else : content = msgdict2 [ uid ] [ key ] if content : print banner print content . strip ( ) print banner else : print '(No such section)'
let the user view various parts of a given message .