Szukaj…


Uwagi

Zobacz także oficjalne odniesienie API dla aplikacji Gmail, aby uzyskać więcej informacji na temat dostępnych metod.

Pobierz plik CSV dołączony do wiadomości e-mail

Załóżmy, że mamy system, który wysyła codzienne raporty pocztą elektroniczną w postaci załączonych plików CSV i że chcemy uzyskać do nich dostęp.

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
Licencjonowany na podstawie CC BY-SA 3.0
Nie związany z Stack Overflow