Recherche…


Remarques

Voir aussi la référence API officielle pour GmailApp pour plus de détails sur les méthodes disponibles.

Obtenir le fichier CSV attaché à un mail

Supposons que nous ayons un système qui envoie des rapports quotidiens par courrier électronique sous la forme de fichiers CSV joints et que nous souhaitons y accéder.

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
Sous licence CC BY-SA 3.0
Non affilié à Stack Overflow