Кажется, я не могу найти ничего, что могло бы выполнить то, что я пытаюсь сделать, и я не настолько опытен в JavaScript, как хотелось бы, поэтому, пожалуйста, потерпите меня ...
Как я уже упоминал в заголовке, я пишу это в скрипте приложений Google ...
Если у меня есть код что-то вроде:
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
});
}
}
Кто-нибудь, пожалуйста, дайте мне указатель на то, как я мог бы выполнить этот последний шаг для переменного числа сообщений в потоке.