Email Body Extraction

Can I extract the body of a message from an email that has been routed to a worker? I tried extracting the raw message from EmailEvent but there was everything else except the body.
export default {
async email(message, env, ctx) {
const reader = message.raw.getReader();
const { value, done } = await reader.read();
const emailContent = new TextDecoder().decode(value);
}
}
export default {
async email(message, env, ctx) {
const reader = message.raw.getReader();
const { value, done } = await reader.read();
const emailContent = new TextDecoder().decode(value);
}
}
1 Reply
Chaika
Chaika15mo ago
You have to use an email parser, like Postal-mime Here's an example from an employee: https://github.com/postalsys/postal-mime You can get the text version of the email (if it has one) or the html version, as well as all the other attributes like attachments, etc
GitHub
GitHub - postalsys/postal-mime: Email parser for browser environments
Email parser for browser environments. Contribute to postalsys/postal-mime development by creating an account on GitHub.
Want results from more Discord servers?
Add your server