Get emails from the filesystem from the `archives_path`
        and store them into the database. If `all` is set to True all
        the filesystem storage will be imported otherwise the
        importation will resume from the last message previously
        imported. The lists set in `exclude_lists` won't be imported.

def import_emails(self, archives_path, all, exclude_lists=None):
        """Get emails from the filesystem from the `archives_path`
        and store them into the database. If `all` is set to True all
        the filesystem storage will be imported otherwise the
        importation will resume from the last message previously
        imported. The lists set in `exclude_lists` won't be imported.

        """

        count = 0
        email_generator = self.get_emails(archives_path, all, exclude_lists)
        for mailinglist_name, msg, index in email_generator:
            try:
                self.save_email(mailinglist_name, msg, index)
            except:
                # This anti-pattern is needed to avoid the transations to
                #   get stuck in case of errors.
                transaction.rollback()
                raise

            count += 1
            if count % 1000 == 0:
                transaction.commit()

        transaction.commit()