Email worker: EmailEvent parsing body?

Hi,

I’d like to create an email worker that receives the email, parse its body and publish it using a rest API, for instance to re-implement the “mail to topic” feature of discourse.

the EmailMessage seems to offer only a raw content, is there an example to parse the body, eg check the html part, of if there is an attachment or anything more high level than the raw stream?

the documentation:

https://developers.cloudflare.com/workers/runtime-apis/email-event/