def METHOD_NAME(to, subject, slack_messages):
    # extract some important activity types into groups
    submissions = [m for m in slack_messages if m.event.type == MESSAGES.NEW_SUBMISSION]
    comments = [m for m in slack_messages if m.event.type == MESSAGES.COMMENT]
    reviews = [m for m in slack_messages if m.event.type == MESSAGES.NEW_REVIEW]
    exclude_ids = [m.id for m in submissions + comments + reviews]  # type: ignore
    messages = [m for m in slack_messages if m.id not in exclude_ids]
    total_count = len(slack_messages)
    ctx = {
        'messages': messages,
        'submissions': submissions,
        'comments': comments,
        'reviews': reviews,
        'has_main_sections': bool(exclude_ids),
        'total_count': total_count,
        'ORG_LONG_NAME': settings.ORG_LONG_NAME,
        'ORG_SHORT_NAME': settings.ORG_SHORT_NAME,
        'ORG_URL': settings.ORG_URL,
    }
    if total_count:
        email = MarkdownMail('messages/email/activity_summary.md')
        email.send(
            to=to,
            subject=subject,
            from_email=settings.SERVER_EMAIL,
            context=ctx,
        )
        logger.info(f"Sent activity digest email to {to}")
    else:
        logger.info('No email generated/sent, as there are no new activities.')