Add attachments in specific mails to drive

To add attachments from specific emails to Google Drive, you can use the following steps:

Method 1: Using Gmail's built-in feature

  1. Log in to your Gmail account and go to the inbox.
  2. Search for the emails that have the attachments you want to save to Google Drive.
  3. Check the boxes next to the emails you want to save.
  4. Click on the "More" menu and select "Forward as attachment".
  5. In the "Forward as attachment" window, select "Google Drive" as the destination.
  6. Choose the folder where you want to save the attachments.
  7. Click "Forward" to save the attachments to Google Drive.

Method 2: Using a third-party add-on

  1. Install the "Gmail Attachments to Drive" add-on from the Google Workspace Marketplace.
  2. Go to your Gmail inbox and search for the emails that have the attachments you want to save to Google Drive.
  3. Check the boxes next to the emails you want to save.
  4. Click on the "Gmail Attachments to Drive" button that appears in the top right corner of the screen.
  5. Select the folder where you want to save the attachments.
  6. Click "Save" to save the attachments to Google Drive.

Method 3: Using a script

  1. Create a new script in Google Apps Script by going to the Google Drive website, clicking on the "Tools" menu, and selecting "Script editor".
  2. In the script editor, paste the following code:
    function saveAttachments() {
    var threads = GmailApp.searchThreads("subject:your-subject");
    var attachments = [];
    for (var i = 0; i < threads.length; i++) {
     var thread = threads[i];
     var messages = thread.getMessages();
     for (var j = 0; j < messages.length; j++) {
       var message = messages[j];
       var attachmentsInMessage = message.getAttachments();
       for (var k = 0; k < attachmentsInMessage.length; k++) {
         attachments.push(attachmentsInMessage[k]);
       }
     }
    }
    var folder = DriveApp.getFolderById("your-folder-id");
    for (var i = 0; i < attachments.length; i++) {
     var attachment = attachments[i];
     folder.createFile(attachment);
    }
    }
  3. Replace "your-subject" with the subject of the emails you want to save, and "your-folder-id" with the ID of the folder where you want to save the attachments.
  4. Save the script and give it a name, such as "Save Attachments".
  5. To run the script, click on the "Run" button or press Ctrl+Enter.
  6. The script will save the attachments from the specified emails to the specified folder in Google Drive.

Note: Make sure to replace the placeholders with the actual values for your specific use case.