Applying a google apps script to a gmail account

Posted on

Applying a google apps script to a gmail account – Despite Gmail excellence, there can be problems in accessing the service. You may not be able to clear out storage space, share files, or are unable to access a document. Thankfully, many Gmail problems are easy to fix. With Gmail, specifically, whether you’re storing and managing your documents, there’s a decent chance you’ll run into some manner of murkiness along the way. We’re going to offer some typical Gmail troubleshooting tips, then solve some specific Gmail problems, like Applying a google apps script to a gmail account, and how to fix it.

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 = 'forward@gmail.com'; 
  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?

Answer :

Leave a Reply

Your email address will not be published. Required fields are marked *