I have almost no experience in coding but I've developed a simple code to extract information from tagged emails.
function getemails() {
var label = GmailApp.getUserLabelByName("Test");
var threads = label.getThreads(); // ARRAY
for (i=0;i<threads.length;i++)
{
SpreadsheetApp.getActiveSpreadsheet().getRange("B"+(i+1)).setValue(threads[i].getMessages()[0].getPlainBody())
}
}
It works with all my tags but It has I've encountered a problem with some of the emails and I was hoping maybe someone could help me fix it.
The emails I'm trying to read have this in the begging of their body:
------------------------------------------------------------------------------------------------------
And for some reason, when extracting the body information, what I get in the value is:
--
id: 7898659753248090
If I remove that line, the body information is extracted perfectly, so the problem is that line.
Is there any way to fix this?