How to trigger a Google Apps Script once an email get in the inbox?

前端 未结 1 953
生来不讨喜
生来不讨喜 2020-12-02 14:14

I have created a Google Apps Script that checks if an email has an attachment then send it to another email address.

It\'s working fine, but I would like to create a

相关标签:
1条回答
  • 2020-12-02 15:17

    After some research and some help from other google-apps-script developers, the best solution is to use a combination of Gmail filtering system in addition to a time-driven-trigger.

    So basically for a normal Gmail account there is a 1 hour/day computing time as mentioned in the documentation See reference here.

    So what I did is set up a filter that adds a Label and a star to the incoming emails that need to be processed.

    In my script I add the Labels in an array, I loop over the array of labels so that I process only the desired emails and not the whole inbox.

    Once processed, the script removes the star from the processed email.

    This way you don't lose your precious compute time, and you don't reach the daily limit.

    I then set a time driven trigger that runs every 10 minutes.

    You can also set up the time driven trigger to send you a daily "Summary of failures " so that you can see what went wrong with your script and fix what has to be fixed.

    0 讨论(0)
提交回复
热议问题