def METHOD_NAME(request):
    input_file = request.params["csvfile"].file
    wrapper = io.TextIOWrapper(input_file, encoding="utf-8")
    rows = list(csv.DictReader(wrapper))
    if rows:
        for row in rows:
            user = request.db.get(User, row["user_id"])
            email = user.primary_email
            if email:
                request.task(send_email).delay(
                    email.email,
                    {
                        "subject": row["subject"],
                        "body_text": row["body_text"],
                        "body_html": row.get("body_html"),
                    },
                    {
                        "tag": EventTag.Account.EmailSent,
                        "user_id": user.id,
                        "additional": {
                            "from_": request.registry.settings.get("mail.sender"),
                            "to": email.email,
                            "subject": row["subject"],
                            "redact_ip": True,
                        },
                    },
                )
        request.session.flash("Mass emails sent", queue="success")
    else:
        request.session.flash("No emails to send", queue="error")
    return HTTPSeeOther(request.route_path("admin.emails.list"))