diff --git a/gmail-tester.js b/gmail-tester.js index 2f7fba5..157e6f1 100644 --- a/gmail-tester.js +++ b/gmail-tester.js @@ -72,6 +72,12 @@ async function _get_recent_email(credentials, token, options = {}) { if (part.parts) { parts = parts.concat(part.parts); } + + if (!part.body.data) { + // body part could be an attachment of type text/plain or text/html + // and the parsing code below will break, hence skipping here + continue; + } if (part.mimeType === "text/plain") { email_body.text = Buffer.from(part.body.data, "base64").toString(