Answer the question
In order to leave comments, you need to log in
Google script how to make a loop from an existing script?
I achieved with this script that the text of the letter would be copied to google docs, the task is that the script would go through all the letters and copy the text to google docs
function myFunction() {
var doc = DocumentApp.getActiveDocument();
var body = DocumentApp.getActiveDocument().getBody();
var thread = GmailApp.getInboxThreads(2,1)[0]; // get first thread in inbox
var message = thread.getMessages()[0]; // get first message
body.insertParagraph(0, message.getBody());
Logger.log(message.getBody()); // log contents of the body
Answer the question
In order to leave comments, you need to log in
You are currently reading the first email in the first thread:
var thread = GmailApp.getInboxThreads(2,1)[0]; // get first thread in inbox
var message = thread.getMessages()[0]; // get first message
You need to decide whether all the letters you need (filter by unread, read a specific label, etc.)
Then, in the array of letters you need, you need to create a loop like:
for (i=0; i<=Number of letters ( chains) in an array; i++) { message
processing
}
Ready to help with the implementation on a specific script [email protected]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question