Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

222
Views
Extract data from Email Body

So i'm writing a script to automatically collect emails to a Google spreadsheet. I would like from this email to extract some details like the email address, the name, the address, the phone number. So far i managed to extract the date, the subject, the sender details and the body contents. Below i'll attach the email body and also the code i've written so far! If you have contact me directly at this emails.

This a code i've tried so far:

    function onOpen(e) {
  var ui = SpreadsheetApp.getUi();
  

  ui.createMenu("KingBoss Menu").addItem("Get Emails", "getGmailEmails").addToUi();
  
}

function getGmailEmails() {
  var label = GmailApp.getUserLabelByName("warranty");
  var threads = label.getThreads();

  for(var i = threads.length - 1; i >=0; i--) {
  var messages = threads[i].getMessages();

    for (var j = 0; j <messages.length; j++) {
      var message = messages[j];
      extractDetails(message);
      GmailApp.markMessageRead(message);
    }
      
  }

}

function extractDetails(message) {
  var dateTime = message.getDate();
  var subjectText = message.getSubject();
  var senderDetails = message.getFrom();
  var bodyContents = message.getPlainBody();
  

  var activeSheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  activeSheet.appendRow([dateTime, senderDetails, subjectText, bodyContents]);
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!