Skip to content

Instantly share code, notes, and snippets.

@shayelkin
Created September 28, 2015 16:29
Show Gist options
  • Save shayelkin/b3debcd665e4060c6e78 to your computer and use it in GitHub Desktop.
Save shayelkin/b3debcd665e4060c6e78 to your computer and use it in GitHub Desktop.
Automatically forward emails from Gmail's inbox to Expensify
// Forwards all emails in the inbox from `from_email` to Expensify, and archive them.
//
// To use:
// Add this function to a Google Apps Scripts project, and add a trigger (in Resources -> Current Project Triggers)
// to call it on a given interval.
// Make sure to specify the senders you'd like to forward!
function toExpensifyBySender(from_email) {
var threads = GmailApp.search('from:' + from_email + ' in:inbox');
for (var i = 0; i < threads.length; i++) {
var messages = threads[i].getMessages();
for (var j = 0; j < messages.length; j++) {
messages[j].forward('receipts@expensify.com')
}
GmailApp.moveThreadToArchive(threads[i]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment