How can I script Google Gmail email forwarding ?

Whilst I know this is probably a Google API Script / Javascipt somewhere that i could use I am having alot of trouble trying to find one that will work as required.

 

I am new to Google API code and was wondering if someone has already devised a solution that i can achieve the following:

 

1.  Time Based filtering in Gmail.

e.g. from 5:30pm - 7:30am i need to forward email from test@test.com to test@test2.com

e.g. From 7:30am - 5:30pm delivery mail to inbox as normal.

2. Need to be able to run the script automatically at 7:30am and 5:30pm.

 

Has anyone got a solution for me or can lead me to a link where i can learn how to get this setup?

 

Cheers

Troy

Has anyone got any suggestions on how I can achieve this

Hi @troygraham,

Thanks for being part of the GitHub Community Forum. We’re glad you’re here.

I wanted to jump in here and mention that “bumping”, in general, is frowned upon. The reason why is that the forum is for people to discuss what they are interested in related to GitHub and general deveopment. If you’re bumping something, then it means that for whatever reason you’re trying to get people to talk about something that they may not want to talk about.

You might also need to look elsewhere for help on this specific problem. Since you’re working with Gmail forwarding, you might want to check out the Google Product forum or one of Google’s developer communities.

That said, if you have relevant, new information that you’d like to update a thread with, that’s fine. But bumping something just to try to get it to populate higher in search results is not allowed. If this particular thread gets bumped again, we’ll have to lock it from further replies.

Thanks!

Hi @troygraham,

I took a look at the Gmail API on filters and the most probable solution would be needing to set up some kind of external script that, at specific times, updates the filter criteria to forward between those times and then revert the changes outside of those hours.

​If there’s anything else I can help you with, let me know; so happy to help further!

Kindest regards,
Matthew

1 Like