Automatically forward "Starred in Gmail" messages to OmniFocus

Solution 1:

Try:

function TJ() {
  var threads = GmailApp.search('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())
      {
        Logger.log(messages[i].getSubject());
        messages[i].unstar();
        messages[i].forward("[email protected]", {
          // Advanced parameters: https://developers.google.com/apps-script/reference/gmail/gmail-message#forward%28String,Object%29
          cc: "[email protected]",
          bcc: "[email protected],[email protected]"
          });     
      }
  }
}
}

For more information regarding Google Apps Script, see this post: http://www.johneday.com/422/time-based-gmail-filters-with-google-apps-script