Skip to content

Commit

Permalink
Merge pull request #18 from bishoy-magdy/bug-#14
Browse files Browse the repository at this point in the history
Bug #14 - Fix: if HTML email content not exist
  • Loading branch information
roman-r-m authored Dec 7, 2022
2 parents 9fe34e7 + 127fb1e commit 34fe1a4
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/core/emailParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() === ''? '<div><br\></div>': `<div>${linebreak}</div>`;
});
return message;
}
return this.emailContent.html || '<div><h1>This Email Has No Body</h1></div>\n';
}
}
Expand Down

0 comments on commit 34fe1a4

Please sign in to comment.