From 127fb1e473bef020fafc266e50470d5c39eecd80 Mon Sep 17 00:00:00 2001 From: Bishoy Magdy Date: Sat, 19 Nov 2022 05:52:08 +0200 Subject: [PATCH] fix: if HTML email content not exist. --- src/core/emailParser.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/core/emailParser.ts b/src/core/emailParser.ts index 52a687d..f3b1ccf 100644 --- a/src/core/emailParser.ts +++ b/src/core/emailParser.ts @@ -26,6 +26,16 @@ export default class EmailParser extends postalMime { } get html() { + // If no html content is found, email text content will be returned if it exists.  + if(!this.emailContent.html && this.emailContent.text){ + let message = ''; + const linebreaks = this.emailContent.text.split('\n'); + + linebreaks.forEach(linebreak => { + message += linebreak.trim() === ''? '
': `
${linebreak}
`; + }); + return message; + } return this.emailContent.html || '

This Email Has No Body

\n'; } }