我希望 monitorEmails 功能在收件箱中查找新邮件。无论出于何种原因,GS 不会读取前两行代码,我知道这一点是因为 Log 只显示第一行
Logger.log(..)
声明已经核实。GS 只记录前几行,除了第一条语句之外不提供任何反馈。
如何让 GS 显示 Logger.log(..) 语句?
这是代码:
//set a time-driven trigger to run this function on the desired frequency
function monitorEmails() {
var thread = GmailApp.getInboxThreads(0,1)[0]; // get first thread in inbox
// log the number of messages in the thread
var firstThread = GmailApp.getInboxThreads(0,1)[0];
var numMsgs = firstThread.getMessageCount(); // # of messages in a given thread
Logger.log(firstThread.getMessageCount());
var messages = firstThread.getMessages();
if (firstThread.isUnread()=='true'){ // check if thread is Read
//Logger.log(firstThread.isUnread()=='true');
for (var i = 0; i < messages.length; i++) { //Go through each message within a Thread
// Logger.log(messages[i].getSubject());
if (messages[i].isUnread()){ // if the message is unread
Logger.log(messages[i].isUnread());
var unreadBody = messages[i].getBody(); // Body contents variable that contains the body
Logger.log(messages[i].getBody());
var unreadFrom = messages[i].getFrom(); // Email Sender contents variable
//Logger.log(messages[i].getFrom());
messages[i].markRead(); // Mark message as read
//Logger.log(messages[i].markRead());
var fullLot = "Full"; // look for "Full" in text message.
//Logger.log(unreadBody.search(fullLot) =='true');
if(unreadBody.search(fullLot) == 'true' && getEmail()==AdminTest()){
// if the sender has the proper admin email / phone #, then call function sendEmails
sendEmails();
}
}
}
}
}
谢谢你的帮助!