Created
September 28, 2015 16:29
-
-
Save shayelkin/b3debcd665e4060c6e78 to your computer and use it in GitHub Desktop.
Automatically forward emails from Gmail's inbox to Expensify
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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('[email protected]') | |
} | |
GmailApp.moveThreadToArchive(threads[i]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Perfect. Thanks.