Thursday, 15 April 2010

How to get subject from gmail and put into a google doc or spreadsheet -


I am trying to automatically remove subject line in Google Doc or spreadsheet. I found a basic example but did not know how it worked.

  Get all threads in the function process inbox () {// inbox word threads = GmailApp.getInboxThreads (); (Var i = 0; i & lt; threads.length; i ++) {// Receive all messages in a given thread var message = thread [i] .getMessages (); // Repeat every message for (var j = 0; j & lt; messages.length; j ++) {// log message subject to Logger.log (message [j] .getSubject ()); }}}}  

this is javascript, java is not script above, your Collects all the messages in a list, which is the right move, but it will not be written in the sheet.

After that you have to add an extra function to write it out. If you are in a spreadsheet, then you can use something like that. I have modified the above function so that the subjects are inserted into the array instead of logging in to the console, and return it to that array.

  function process inbox () {var threads = GmailApp.getInboxThreads (); Var topics = [[]]; (Var i = 0; i & lt; threads.length; i ++) {var message = thread [i] .getMessages (); (Var j = 0; j & lt; messages.length; j ++) {topics [j] = [message [j] .getSubject ()]; }} Return topics; } Write the function autosibix () {var ss = SpreadsheetApp.getActiveSpreadsheet (); Var letter = ss.getSheets () [0]; Var topics = process inbox (); Var rang = sheet.getRange (1,1, subject length, 1); Range.setValues ​​(topics); };  

No comments:

Post a Comment