It seems that at the moment Google Script does not allow direct access to messages sent using a specific method. At least it does not appear in the official doc.
However, you can use the search
method of GmailApp, evaluating the condition is:sent
and searching the thread 0
(the root of the sent messages).
In this example, it is indicated that you search for the first 5
messages in the folder enviados
and the subject getFirstMessageSubject
will be displayed iterating over the array enviados
. You can use any other method to get the data that interests you.
In this way you can access the messages sent without having to go through complicated methods such as knowing the id of the message, etc.
You can apply a series of interesting filters by combining them with the search
method. You can filter messages by folders, by labels, by recipients, by date ranges ... In this link you will see some examples that could be useful when filtering the messages you want to get.
var enviados = GmailApp.search("is:sent", 0, 5);
for (var i = 0; i < enviados.lenght; i++)
{
Logger.log (enviados[i].getFirstMessageSubject());
}
Sample result
You can see a result similar to this if you click on the Ver - > Registros
Google Script menu.
[17-04-12 19:36:54:792 CEST] Liturgia de la Semana Santa: Celebraciones del 10 al 16 de Abril, Pascua de la Resurrección de Nuestro Señor Jesucristo y Domingo 23 de Abril
[17-04-12 19:36:54:842 CEST] Domingo de Ramos
[17-04-12 19:36:54:899 CEST] PASAJE AVE
[17-04-12 19:36:54:955 CEST] Liturgia de la Semana V del Tiempo de Cuaresma: Celebraciones del 3 al 9 de Abril y el Domingo 16 de Abril
[17-04-12 19:36:55:022 CEST] Liturgia de la Semana IV del Tiempo de Cuaresma: Celebraciones del 27 de Marzo al 2 de Abril y el Domingo 9 de Abril