I'm a complete noob.
I'd like to forward labelled emails on the 1st of every month to another email address. Using Gmail's filters, the label "forwardthis" get applied to my invoices and statements I received during the month. On the 1st of every month, I'd like Google scrips to forward all new emails with the "forwardthis" label to another email address, including attachments.
The script I found doesn't work as I hoped. Not sure what the interval options below are for, but I need to run my script only once a month, on the 1st.
function autoForward() {
var label = 'forwardthis';
var recipient = '[email protected]';
var interval = 5; // if the script runs every 5 minutes; change otherwise
var date = new Date();
var timeFrom = Math.floor(date.valueOf()/1000) - 60 * interval;
var threads = GmailApp.search('label:' + label + ' after:' + timeFrom);
for (var i = 0; i < threads.length; i++) {
threads[i].getMessages()[0].forward(recipient); // only the 1st message
}
}
Hope my question is clear. I'll greatly appreciate some guidance, thanks.