1
我試圖從以前的舊版羣組發帖中獲取以下Google Apps腳本以進行工作。它基本上正在調用getThreads(n,m)的地方。返回的錯誤代碼是:getThreads()for Gmail在Google Apps中返回NULL
TypeError:無法調用null的方法「addToThreads」。
有沒有更簡單的方法來調試getThreads()函數?目標是將標籤從EVERNOTE更改爲Scripts/Forward。
// Set up multiple labels/sub-labels and add one or more email addresses
function forwardEmails() {
forwardThreads("EVERNOTE", "[email protected]", "@Filtered Email Archive");
// forwardThreads("Forward/MoreItems", "[email protected], [email protected]", "MORE INFO");
}
function forwardThreads(label, addr, subjSuffix) {
var maxSubjLength = 250;
var applylabel = GmailApp.getUserLabelByName("Scripts/Forward");
// Send individual and threaded emails.
var msgs, msg, i, j, subject, options, labels, page;
labels = GmailApp.getUserLabelByName(label)
var threads = labels.getThreads()
for (i=0; i < threads.length; i++) {
msgs = threads[i].getMessages();
for (j=0; j < msgs.length; j++) {
msg = msgs[j];
subject = msg.getSubject();
if (subject.length + subjSuffix.length > maxSubjLength) {
subject = subject.substring(0, maxSubjLength - subjSuffix.length);
}
options = { htmlBody: msg.getBody(), attachments : msg.getAttachments() };
GmailApp.sendEmail(addr, subject +" "+ subjSuffix, msg.getBody(), options);
}
}
while(!page || page.length == 100) {
page = labels.getThreads(0, 100);
// Apply new label; move the thread out of other label
applylabel.addToThreads(page); // ***** Failing on this line - assume page is NULL
labels.removeFromThreads(page);
}
}
謝謝MB。我回到了(我的)Gmail帳戶。我創建了一個標籤Scripts/Forward而不是Forward。當我更正標籤名稱時,它正確運行。 – gadams999 2012-08-12 16:48:20