Filtering Gmail to Find Office 365 Store and Forward Messages

WARNING: The TSO Help Desk does not support Gmail.  If you decide to use Gmail as a Store and Forward destination, you do so at your own risk.  The information in this HowTo has been provided for your benefit, and is unsupported.

If you use the Store and Forward option with Gmail as a destination, you may be interested in identifying which messages have arrived via that functionality.  Unfortunately, there is no simple method to filter for these messages.  However, it is possible to tag these messages with a Gmail Label of your choice using Google's scripting functionality. 

  1. Go to https://www.google.com/script/start/ and click "Start Scripting".
  2. Grab the code from http://b.gatech.edu/1MqarVj and replace the starter code. Edit the label name and email address at the top (O365LABEL and LOOPADDR, respectively). Then save the file and name the project.
  3. Optionally, test the script using the Run menu (or triangle button). If you have any new Office 365 mail forwards in the last hour, the new label should be applied.
  4. To make the script run every hour, choose “Current Project’s Triggers” from the Resource menu.
  5. Click the "No triggers set up. Click here to add one now." link to create a new trigger.
  6. The default is an hourly trigger.  If that will be sufficient, select "Save".  Otherwise, change the trigger to your satisfaction and select "Save".

Now that Labels are being applied on a scripted basis, it should be a simple matter to process them using Gmail's built-in filtering functionality (which is beyond the scope of this HowTo).