hgfghddf

drive->gmail

Jul 12th, 2023
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function makeFolderDrive(){
  2.   const folder = DriveApp.createFolder('Załączniki z mailów');
  3.   const threads = GmailApp.search('has:attachment');
  4.   const attachments = [];
  5.   threads.forEach(thread => {
  6.     thread.getMessages().forEach(message => {
  7.       const senderEmail = message.getFrom();
  8.       message.getAttachments({includeInlineImages: false}).forEach(attachment => {
  9.         const file =
  10. folder.createFile(attachment.copyBlob().setName(senderEmail + " - " + attachment.getName()));
  11.         attachments.push(senderEmail + " - " + attachment.getName());
  12.       })
  13.     })
  14.   })
  15.   Logger.log(attachments);
  16. }
Tags: Kuba
Advertisement
Add Comment
Please, Sign In to add comment