I'm asking a question relating to the code on this post
How can I automatically forward Gmail emails when a label is applied?
function autoForward() {
var label = 'forwardthis';
var recipient = '[email protected]';
var interval = 5; // if the script runs every 5 minutes; change otherwise
var date = new Date(); var timeFrom = Math.floor(date.valueOf()/1000) - 60 * interval;
var threads = GmailApp.search('label:' + label + ' after:' + timeFrom);
for (var i = 0; i < threads.length; i++) { threads[i].getMessages()[0].forward(recipient); // only the 1st message } }
Forward every message in the thread
var messages = threads[i].getMessages();
for (var j = 0; j < messages.length; j++) {
messages[j].forward(recipient);
}
Forward the last message in the thread
var messages = threads[i].getMessages();
messages[messages.length - 1].forward(recipient);
I've made it into a script, set a trigger, set the APIs and yet I still can't get this to do what it should, ie, forward an email to an email address when it is labelled.
What is the process for getting this from code through to application within the Google suite?