I am trying to forward an email and add a paragraph after the 6th paragraph in the original message which looks like this:
p1
p2
p3
p4
p5
p6
p7
p8
p9
I have this script (only part of it is shown below):
var body = messages[j].getPlainBody();
var firstpart = body.split("\n")[7,8,9]);
var secondpart = body.split("\n")[1,2,3,4,5,6]);
GmailApp.sendEmail(recipient,subject, '', {htmlBody: "blabla" + body});
Instead of this, I would like to have something like that:
var body = messages[j].getPlainBody();
var firstpart = body.split("\n")[7,8,9]);
var secondpart = body.split("\n")[1,2,3,4,5,6]);
GmailApp.sendEmail(recipient,subject, '', {htmlBody: firstpart + "blabla" + secondpart});
This does not work, as the split returns only one paragraph. Is there a way to include all first 6 paragraphs and all last paragraphs in variables?
Many thanks in advance!