type.inbound
and any(attachments,
not (
.file_type == "ics"
or .file_extension == "ics"
or .content_type in ("application/ics", "text/calendar")
)
and any(file.explode(.),
any(.scan.url.urls,
strings.decode_hex(.fragment) == recipients.to[0].email.email
)
)
)
Playground
Test against your own EMLs or sample data.