Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9782

Why does this Google Apps script for Gmail not do anything?

$
0
0

I am using the following script from Any way to send Gmail auto-response at certain times every week?. It does not send the expected email.

function autoReply() {var interval = 5;    //  if the script runs every 5 minutes; change otherwise  var date = new Date();  var day = date.getDay();  var hour = date.getHours();  if ([5,6,0].indexOf(day) > -1 || (day == 1 && hour < 8) || (day == 4 && hour >= 17)) {    var timeFrom = Math.floor(date.valueOf()/1000) - 60 * interval;    var threads = GmailApp.search('is:inbox after:'+ timeFrom);    for (var i = 0; i < threads.length; i++) {      if (threads[i].isUnread()){      threads[i].reply("I am out of office. Your email will not seen until Monday morning.");      threads[i].markRead();      threads[i].markImportant();      }    }  }}

To test the script I sent emails from another address. I've tested many times with clicking run both before and after the emails were received. I don't believe that should make a difference because the script should run again after the specified interval.

The Execution log shows that the script completes immediately after it starts.


Viewing all articles
Browse latest Browse all 9782

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>