0
votes

I checked out the following question which has an example relating Gmail and Google Sheets: How to use Google App Scripts to retrieve Gmail emails in a customised way?

I'm wondering how I could add additional parameters: message date, sender email, message subject, full message body.

The problem with the above script is it retrieves the last email address from any thread in the inbox. I'm concerned with threads as well as individual messages.

Last, I'd love to add a clause that specifies to only grab message data for those messages that I've tagged in Gmail.

Here's some documentation on Gmail API and Google Sheets.

2

2 Answers

1
votes

I think what you need here is Google Apps Script. So by checking the documentation, you can find the different methods that you can do in Gmail message.

For your question:

How I could add additional parameters: message date, sender email, message subject, full message body.

As you can see in the above document. You will find here the method getDate() that will get the date and time of the message.

var thread = GmailApp.getInboxThreads(0,1)[0]; // get first thread in inbox
var message = thread.getMessages()[0]; // get first message
Logger.log(message.getDate()); // log date and time of the message

Check the other link for some sample code of each parameter.

Also just check the documentation of AppScript on how to send this to a Spreadsheet.

0
votes

For Question How I could add additional parameters: message date, sender email, message subject, full message body. refer this documentation.

For App-script on how to send this to a Spreadsheet. First create Spreadsheet in drive refer below code to add to it.

  var ss = SpreadsheetApp.open(DriveApp.getFilesByName('ADD NAME').next()).getSheets()[0]; ss.appendRow(["RESULT"])