I added the following messages (and not the entire stream) to the label with the to_processfollowing steps:
Disable Conversation Modein Gmail settings
Apply shortcut to_processto specific messages
When displaying messages, I can confirm that only specific messages have been added. For example, another message that is in the same thread has no label . It's good.
Now I would like to use all these messages from Google Apps Script. But the problem is that the API can only provide access to streams attached to a specific label:
var threads = GmailApp.search('label:to_process');
for (var i = 0; i < threads.length; i++) {
}
or
var label = GmailApp.getUserLabelByName("to_process");
var threads = label.getThreads();
for (var i = 0; i < threads.length; i++) {
}
How to loop through messages (not threads) associated with a tag?
The beginning of the solution, but I do not know how to proceed:
var threads = GmailApp.search('label:to_process');
for (var i = 0; i < threads.length; i++) {
var messages = threads[i].getMessages();
for (var j = 0; j < messages.length; j++) {
var message = messages[j];
}
}