Question

Hello guys I am working on a project where I want to read emails from gmail inbox on a specific date. I have referred the official documentation but it hasn't been much helpful to me.

var master = SpreadsheetApp.openById(<SPREADSHEET_ID>);
var demosheet = master.getSheetByName("demo");
var newDate = Utilities.formatDate(new Date(), "GMT+5:30", "dd/MM/YYYY");
var getdate = demosheet.getDataRange().getValues();
var firstThread = GmailApp.getInboxThreads(0,1)[0];
//to get date from spreadshet
for(i=2;i<getdate.length;i++)
{
Logger.log(firstThread.getLastMessageDate(getdate[i][0]));  }}

Can anyone please help, thanks in advance.

Was it helpful?

Solution

Look at GmailApp.search. Google for search format as its not in the docs. Probably uses syntax 'before:x after:y

https://developers.google.com/apps-script/reference/gmail/gmail-app?hl=ja#search(String,Integer,Integer)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top