Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Summary: I would like to create some sort of an automated process where any messages that I 'star' in Gmail (aka 'flag' when using Gmail via IMAP) will automatically be added to OmniFocus, and then "unstarred" on Gmail and moved to another specific label called "OmniFocus".

I am quite sure that this is possible with Google Scripts but I cannot figure out how to get it to work. I would like that solution because it would not require me to run anything else on my own Mac.

Also: I have an account with which means that I can add things to my OmniFocus Inbox by sending email to a specific email address.

My idea for a Google Script would go something like this:

  • every ¿15? minutes or so, check for flagged messages in Gmail, and if found:
  • forward to my Super Secret Spootnik Email Address
  • Add label 'OmniFocus' to message
  • unstar/unflag message in Gmail

Unfortunately I don't know to make this work in Google Scripts, so I'm wondering if someone else might know and be able to explain it to others who might want to do something similar.


While I would prefer Google Scripts, I do have a Mac which is usually on 24/7 anyway, so if that is the only way to do this, that would also be an option. Unfortunately I have even less of an idea how to do that. (I assume + AppleScript?)

share|improve this question
would be an option as well? – patrix Apr 8 '13 at 20:25
That's a good thought but I couldn't make it work. It can trigger off a new flagged message but not do something with that message itself. – TJ Luoma Apr 9 '13 at 2:21
up vote 2 down vote accepted


function TJ() {
  var threads ='label:inbox is:starred');
  for (var h = 0; h < threads.length; h++) {
    var messages = threads[h].getMessages();
    for (var i = 0; i < messages.length; i++) {
      if (messages[i].isStarred())
        messages[i].forward("", {
          // Advanced parameters:,Object%29
          cc: "",
          bcc: ","

For more information regarding Google Apps Script, see this post:

share|improve this answer
Yes! This worked perfectly. I used the "CC:" to send it to myself "" and then created a rule which automatically marked that as read and applied the label "omnifocus" to it. Thanks again! – TJ Luoma Apr 9 '13 at 14:55

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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