转自 https://www.moeelf.com/archives/4.html
function autoReplier() {
var labelObj = GmailApp.getUserLabelByName('autoreply');
var gmailThreads;
var messages;
var sender;
for (var gg = 0; gg < labelObj.getUnreadCount(); gg++) {
gmailThreads = labelObj.getThreads()[gg];
messages = gmailThreads.getMessages();
for (var ii = 0; ii < messages.length; ii++) {
if (messages[ii].isUnread()) {
msg = messages[ii].getPlainBody();
sender = messages[ii].getFrom();
MailApp.sendEmail(sender, "Auto Reply", "Hi, 您好!这是一条自动回复短信!本短信由 Google Apps Script 自动发出。");
messages[ii].markRead();
messages[ii].moveToTrash();
}
}
}
}