我似乎无法找到任何可以完成我想要做的事情,而且我不像我想的那样精通JavaScript,所以请耐心等待。 .. 正如我在标题中提到的,我在谷歌应用程序脚本中写这个......
如果我有类似的代码:
function getMails() {
// get the first 5 threads
var threads = GmailApp.getInboxThreads(0, 5);
// get all the messages for the threads selected
var messages = GmailApp.getMessagesForThreads(threads);
// iterate through the threads
// ('messages' being the first message of the thread)
for (var i = 0; i < messages.length; i++) {
// then iterate through every message of the thread
var blobs = [];
for (var j = 0; j < messages[i].length; j++) {
// create a blob for every message
var blob = Utilities.newBlob(messages[i][j].getRawContent(),
'text/plain',
'message' + j + '.eml');
// push the blob into the array
blobs.push(blob);
}
// here's where I think I'm having trouble finding a solution
// and I do not want to zip all the blobbed messages into 1
MailApp.sendEmail(Session.getActiveUser().getEmail(),
"thread report: [" + messages[i][0].getSubject() + "]",
"attached message as text/plain", {
name: 'Automatic Emailer Script',
attachments: blobs
});
}
}
&#13;
有人请给我一个指针,告诉我如何为每个线程的可变数量的消息完成最后一步。
答案 0 :(得分:0)
阅读评论并重新尝试代码(并修复一些我错过的东西,因为我在运行中编写它并没有复制并粘贴我的工作/非工作代码)我得到了它的工作!感谢大家对您的意见和见解的帮助。问题中的代码已经过编辑,并且正在按预期工作。