Sök…


Anmärkningar

Se även den officiella API-referensen för GmailApp för mer information om tillgängliga metoder.

Få CSV-fil bifogad till en e-post

Antag att vi har ett system som skickar ut dagliga rapporter via e-post i form av bifogade CSV-filer och att vi vill komma åt dessa.

function getCsvFromGmail() {
  // Get the newest Gmail thread based on sender and subject
  var gmailThread = GmailApp.search("from:[email protected] subject:\"My daily report\"", 0, 1)[0];
  
  // Get the attachments of the latest mail in the thread.
  var attachments = gmailThread.getMessages()[gmailThread.getMessageCount() - 1].getAttachments();
  
  // Get and and parse the CSV from the first attachment
  var csv = Utilities.parseCsv(attachments[0].getDataAsString());
  return csv;
}


Modified text is an extract of the original Stack Overflow Documentation
Licensierat under CC BY-SA 3.0
Inte anslutet till Stack Overflow