def process_email():
 streams = MessageStream.objects.filter(trash=False, incoming_server_username__isnull=False)
 for stream in streams:
  stream.process_email()

def process_email ( ) : streams = MessageStream . objects . filter ( trash = False , incoming_server_username__isnull = False ) for stream in streams : stream . process_email ( )
parse emails and save activity log entry .