GmailApp is a Google Apps Script service through which the mailbox of the user executing the script can be accessed. The GMailApp reference page includes the getDraftMessages() method, but there is no similar method for draft messages. How can I get the messages in the sent folder?
Gmail, instead of using folders to organize messages, uses labels, of which there are two main types, system labels and user labels.
In addition to getDraftMessages() , there are other methods to get tagged messages from the system, but as mentioned in the question there is no such method for sent tagged messages. As for the GmailMessage Class , there is the isDraft() method but there is no similar one to ask if a message has the system tag
SENT
.Therefore, the alternative that remains is to use a search, based on Search Operators that you can use with Gmail , with the operator
in:sent
orlabel:sent
.The following example logs the number of threads with the tag
SENT
.