Within Gmail, is there any way to automatically forward an email when I apply a label?

Gmail filters appear to only work with new emails. For my needs, applying the label is a manual process after the email was received.


Here is an Apps Script solution. Save it, changing the label and recipient, and set a trigger to run this function every 5 minutes.

It searches for threads with the given label that were created after the last time the script ran. In each, it forwards the first message to the given address.

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

I add some variations, replacing the line with "only the 1st message":

Forward every message in the thread

var messages = threads[i].getMessages();
for (var j = 0; j < messages.length; j++) {

Forward the last message in the thread

var messages = threads[i].getMessages();
messages[messages.length - 1].forward(recipient);
  • This is definitely a great step forward. I can see how this would possibly solve the problem, however, how would I prevent the script from forwarding the same message again and again. Also, what about old email that I wanted to forward? – Aaron Jul 26 '16 at 19:37
  • The after parameter makes sure that the script only looks at the emails from the last 5 minutes, which is after the previous time it ran. As for old messages with that label, you can forward them by temporarily removing ' after:' + timeFrom part, and running script manually once. – user79865 Jul 26 '16 at 19:40
  • 3
    I modified this a little, and instead of using a date check, I created a label ForwardThis and a nested label ForwardThis/Forwarded. The script looks for any messages in ForwardThis and forwards them, and removes the ForwardThis label and applies the ForwardThis/Forwarded label. Lets me stage any messages, regardless of age, for forwarding. Thanks for the idea! – Dave Martorana Jan 12 '17 at 16:23
  • @DaveMartorana Can you share your script? I would like to see an example. – botenvouwer Dec 6 '17 at 21:16
  • 2
    @botenvouwer sure - I use a mac/iOS app called "Deliveries" to track packages, and it integrates with Amazon receipts. All other shipping notifications get forwarded to them for processing. Just so you know what's going on: gist.github.com/themartorana/5fe0c4543e46213686d22580fe47969f – Dave Martorana Dec 14 '17 at 15:11

The 3rd-party service IFTTT (If This Then That) makes this possible. Use the first Gmail trigger "New email labeled...". It doesn't have to be a new email, just newly labeled. May take a bit to trigger.

  • 1
    I just tested it and it seems to work a treat. – ale Jul 27 '16 at 17:10
  • Really worked for me, the applet link is ifttt.com/applets/214039p-auto-forward-mail-from-gmail The only bad thing is it fowards a unique email for every reply of the original email, so big conversations can 'spam' your inbox a little. I don't solve it yet, but it seems like it's possible to configure. It worked fast for me. – jards Jun 28 '17 at 15:09
  • @jards I tried and failed to address the trouble you described: I forwarded an email thread with 3 emails in total, and each individual email got forwarded individually when I applied the label. Could you clarify how to possibly configure things properly? I find the IFTTT fields limited, as of telling "thread" apart from "individual emails." – llinfeng Feb 26 at 20:46

No, sorry. The only automation available in Gmail by itself is Gmail Filters, which act on messages as they arrive. There's nothing built-in to Gmail that allows something to happen when a label is added to a message (unless it's part of a filter acting on an incoming message).

protected by Community Mar 29 at 2:10

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.