我已在消息中添加了标签,如下面的lifehacker链接中所述。
我希望将客户电子邮件标记为"客户" 7天后移至INBOX / Clients文件夹。
提前致谢!
我知道有code for cleaning the mail-box
function cleanUp() {
var delayDays = 2 // Enter # of days before messages are moved to trash
var maxDate = new Date();
maxDate.setDate(maxDate.getDate() - delayDays);
var label = GmailApp.getUserLabelByName("delete me");
var threads = label.getThreads();
for (var i = 0; i < threads.length; i++) {
if (threads[i].getLastMessageDate() < maxDate) {
threads[i].moveToTrash();
}
}
}
但我需要移动电子邮件。怎么做?
答案 0 :(得分:0)
尝试这样的事情
function moveUp() {
var delayDays = 7 // Enter # of days before messages are moved to trash
var maxDate = new Date();
maxDate.setDate(maxDate.getDate() - delayDays);
var label1 = GmailApp.getUserLabelByName("clients1"); // FROM
var label2 = GmailApp.getUserLabelByName("clients2"); // TO
var threads = label1.getThreads();
for (var i = 0; i < threads.length; i++) {
if (threads[i].getLastMessageDate() < maxDate) {
threads[i].addLabel(label2).removeLabel(label1).moveToArchive();
}
}
}
label1
来自标签label1
是标签如果您不需要存档该帖子,则可以删除.moveToArchive()
。