0

I want to use this answer to remove all attachments for certain emails which have > 5 MB attachment.

In order to do this, I first search, in the Gmail GUI, has:attachment larger:5m, and then I add these threads to a label to_process. Then I can run the method shown here:

var emails = GmailApp.search('label:to_process'); 
for (var i = 0; i < emails.length; i++) {
    removeAttachment(...);
}

Problem: when there is a thread with 10 messages and only one of them has a > 5MB attachment, then all the messages of this thread will be in to_process label!

I see here a method to only add messages and not threads to a label, but I still haven't found a solution for this:

How to add all messages with a > 5 MB attachment to this label, but only the messages, without adding all the thread?

Basj
  • 41,386
  • 99
  • 383
  • 673
  • The easiest way is to [Turn Off Conversation View](https://support.google.com/mail/answer/5900) in settings and run the script – random-parts Oct 10 '17 at 03:18
  • @random-parts Good idea about "Conversation Mode off" but I can't find a way to [loop on messages (not threads) of a specific label](https://stackoverflow.com/questions/46670565/looping-on-messages-not-threads-of-a-specific-gmail-label). – Basj Oct 10 '17 at 15:31

0 Answers0