使用Google脚本为Gmail邮件加注星标

时间:2013-04-04 19:17:24

标签: google-apps-script gmail message

我对谷歌脚本完全陌生,我正试图找出如何标记我已标记为“R / R(短)/ R(ASAP)”的消息,并且至少保留了该标签一天。有什么建议?这是我到目前为止所得到的:

function star2do() {
var delayDays = 1 // Enter # of days before messages are starred
var maxDate = new Date();
maxDate.setDate(maxDate.getDate()-delayDays);
var label = GmailApp.getUserLabelByName("R/R(short)/R(ASAP)");
var threads = label.getThreads();
for (var i = 0; i < threads.length; i++) {
if (threads[i].getLastMessageDate()<maxDate)
  {
    threads[i].markUnread();
    threads[i].addLabel(star) //this is where I'm having issues
  }
}
}

1 个答案:

答案 0 :(得分:3)

threads[i].getMessages()[0].markUnread().star();

希望这会有所帮助:)