I created an script that can transfer my gmail attachment to gdrive, but I have to modify my script since it downloads all the gmail attachment even its already downloaded.
May I know what I need to modify on my script?
function saveGmailToGdrive(){
const folderId = "GDRIVE"
const searchItem = "label:MONEY"
const threads = GmailApp.search(searchItem,0,100)
threads.forEach((thread) => {
const messages = thread.getMessages()
messages.forEach((message) => {
const attachments = message.getAttachments({
includeInlineImages:false,
includeAttachments:true
})
attachments.forEach((attachment) => {
Drive.Files.insert({
title:attachment.getName(),
mimeType:attachment.getContentType(),
parents:[{id:folderId}]
},
attachment.copyBlob()
)
})
})
})
}
I hope someone can help me thank you!