function anexos() { var emails; var nomeMarcador = "Anexos"; var marcador = GmailApp.getUserLabelByName(nomeMarcador); if ( !marcador ) { marcador = GmailApp.createLabel(nomeMarcador); } emails = GmailApp.search("has:attachment"); for (var e = 0; e < emails.length; e++ ) { var assunto = emails[e]; marcador.addToThread(emails[e]); Logger.log(assunto.getFirstMessageSubject()) //GmailApp.moveThreadToTrash(assunto); } }