How to export Emails to Excel / Google Sheets

If you need your emails in a spreadsheet, here’s exactly how to do it. There are apps that will parse and export your email messages and parsed data to Google spreadsheet. ActorAi can also help you with this.

Here’s a concise list of common use cases for exporting emails to Excel or Google Spreadsheets:

  • Export order and shipping notifications.
  • Export email leads for CRM or database updates.
  • Parse bounced email addresses for list management.
  • Share open issues or requests with teams using shared spreadsheets.
  • Import structured email data into databases or business applications.
  • Back up and archive important business emails.
  • Create distribution lists from contacts and addresses.
  • Extract financial and expense information for reporting.

Export Emails from Gmail to Google Sheets

Option A – With Google Workspace Add-on (easiest)

  • Open Google Sheets → Extensions → Add-ons.
  • Search for “Gmail to Sheets” add-on (choose one that fits your needs)
  • Install and connect Gmail account.
  • Select label/folder or search filter.
  • Run export → data appears in your Sheet.
  • Tip: set up auto-refresh to update daily.

Option B – With Google Apps Script (DIY method)

  • Pulls emails that match a Gmail search (label, from:, subject:, after:, etc.)
  • Writes them into the active sheet with clean columns
  • Adds a custom menu: Email Export → Run export
  • Lets you control: search query, max emails, and whether to include message bodies

Set up Google Apps Script (DYI method to export to excel)

  1. Open a new Google Sheet.
  2. Extensions → Apps Script.
  3. Delete any code and paste the script below.
  4. Click Save, then RunonOpen() to add the custom menu.
  5. Back in the Sheet, go to Email Export → Setup sheet (it creates a Config tab and headers).
  6. Enter your search in Config!B2 (examples below), then Email Export → Run export.
/**************************************
 * Gmail → Google Sheets Exporter
 * Simple, DYI method for tech advanced.
 **************************************/

const CONFIG_SHEET = 'Config';
const OUTPUT_SHEET = 'Emails';
const PROPERTY_STORE = PropertiesService.getDocumentProperties();

function onOpen() {
  SpreadsheetApp.getUi()
    .createMenu('Email Export')
    .addItem('Setup sheet', 'setupSheet')
    .addItem('Run export', 'exportEmails')
    .addToUi();
}

function setupSheet() {
  const ss = SpreadsheetApp.getActive();
  // Config sheet
  let conf = ss.getSheetByName(CONFIG_SHEET);
  if (!conf) conf = ss.insertSheet(CONFIG_SHEET);
  conf.clear();

  conf.getRange('A1').setValue('Setting');
  conf.getRange('B1').setValue('Value');

  const rows = [
    ['Search query', 'label:inbox newer_than:30d'], // B2
    ['Max emails to fetch (per run)', 500],          // B3 (limit to avoid timeouts)
    ['Include message body? (true/false)', false],   // B4
    ['Body max characters', 5000],                  // B5
    ['Continue from last run? (true/false)', false]  // B6
  ];
  conf.getRange(2, 1, rows.length, 2).setValues(rows);
  conf.autoResizeColumns(1, 2);

  // Output sheet
  let out = ss.getSheetByName(OUTPUT_SHEET);
  if (!out) out = ss.insertSheet(OUTPUT_SHEET);
  out.clear();

  const headers = [
    'Date',
    'From',
    'To',
    'Subject',
    'Snippet',
    'Thread ID',
    'Message ID',
    'Labels',
    'Has Attachments',
    'Thread Link',
    'Message Link',
    'Body (optional)'
  ];
  out.getRange(1, 1, 1, headers.length).setValues([headers]);
  out.setFrozenRows(1);
  out.autoResizeColumns(1, headers.length);

  SpreadsheetApp.getUi().alert('Setup complete. Enter your query in Config!B2, then run "Email Export → Run export".');
}

function getConfig_() {
  const ss = SpreadsheetApp.getActive();
  const conf = ss.getSheetByName(CONFIG_SHEET);
  if (!conf) throw new Error('Config sheet missing. Run "Setup sheet" first.');

  const getVal = (row) => conf.getRange(row, 2).getValue();

  return {
    query: String(getVal(2) || '').trim(),
    maxEmails: Number(getVal(3) || 500),
    includeBody: String(getVal(4)).toLowerCase() === 'true',
    bodyMaxChars: Number(getVal(5) || 5000),
    continueFromLast: String(getVal(6)).toLowerCase() === 'true',
  };
}

function exportEmails() {
  const cfg = getConfig_();
  if (!cfg.query) throw new Error('Please fill a Gmail search in Config!B2.');

  const ss = SpreadsheetApp.getActive();
  const out = ss.getSheetByName(OUTPUT_SHEET) || ss.insertSheet(OUTPUT_SHEET);

  // Resume support (optional)
  let startIndex = 0;
  if (cfg.continueFromLast) {
    startIndex = Number(PROPERTY_STORE.getProperty('startIndex') || 0);
  } else {
    PROPERTY_STORE.deleteProperty('startIndex');
    // If not continuing, start fresh by clearing previous rows (keep header)
    const lastRow = out.getLastRow();
    if (lastRow > 1) out.getRange(2, 1, lastRow - 1, out.getLastColumn()).clearContent();
  }

  const BATCH_SIZE_THREADS = 100; // Gmail returns threads, we’ll page through them
  const rows = [];
  let fetchedEmails = 0;

  while (fetchedEmails < cfg.maxEmails) {
    const threads = GmailApp.search(cfg.query, startIndex, BATCH_SIZE_THREADS);
    if (!threads.length) break;

    for (const thread of threads) {
      const msgs = thread.getMessages();
      for (const msg of msgs) {
        if (fetchedEmails >= cfg.maxEmails) break;

        const date = msg.getDate();
        const from = msg.getFrom();
        const to = msg.getTo();
        const subject = msg.getSubject() || '';
        const snippet = msg.getPlainBody().slice(0, 120).replace(/\s+/g, ' ').trim();
        const threadId = thread.getId();
        const msgId = msg.getId();
        const labels = thread.getLabels().map(l => l.getName()).join(', ');
        const hasAttachments = msg.getAttachments().length > 0;

        const threadLink = `https://mail.google.com/mail/u/0/#all/${threadId}`;
        const messageLink = `https://mail.google.com/mail/u/0/#inbox/${msgId}`;

        let body = '';
        if (cfg.includeBody) {
          // Prefer plain body; fallback to HTML stripped
          body = msg.getPlainBody();
          if (!body) {
            const html = msg.getBody();
            body = stripHtml_(html);
          }
          if (cfg.bodyMaxChars > 0 && body.length > cfg.bodyMaxChars) {
            body = body.slice(0, cfg.bodyMaxChars) + '…';
          }
        }

        rows.push([
          date,
          from,
          to,
          subject,
          snippet,
          threadId,
          msgId,
          labels,
          hasAttachments,
          threadLink,
          messageLink,
          body
        ]);

        fetchedEmails++;
      }
      if (fetchedEmails >= cfg.maxEmails) break;
    }

    startIndex += BATCH_SIZE_THREADS;
    // Safety: avoid 6-minute execution limit
    if (Utilities.getRemainingDailyQuota && rows.length >= 5000) break;
  }

  if (rows.length) {
    out.insertRowsAfter(out.getLastRow() || 1, rows.length);
    out.getRange(out.getLastRow() - rows.length + 1, 1, rows.length, rows[0].length).setValues(rows);
    out.autoResizeColumns(1, out.getLastColumn());
  }

  if (cfg.continueFromLast) {
    PROPERTY_STORE.setProperty('startIndex', String(startIndex));
  }

  SpreadsheetApp.getUi().alert(`Export complete: ${fetchedEmails} emails added.`);
}

function stripHtml_(html) {
  // Lightweight HTML → text
  return String(html || '')
    .replace(/<style[\s\S]*?<\/style>/gi, '')
    .replace(/<script[\s\S]*?<\/script>/gi, '')
    .replace(/<[^>]+>/g, ' ')
    .replace(/\s+/g, ' ')
    .trim();
}

Simple script version for google sheets.

function exportSimple() {
  const sheet = SpreadsheetApp.getActiveSheet();
  const query = 'label:inbox newer_than:7d';
  const threads = GmailApp.search(query, 0, 100);
  const rows = [['Date','From','Subject','Snippet','Thread Link']];
  threads.forEach(t => {
    t.getMessages().forEach(m => {
      rows.push([
        m.getDate(),
        m.getFrom(),
        m.getSubject(),
        m.getPlainBody().slice(0,120).replace(/\s+/g,' ').trim(),
        'https://mail.google.com/mail/u/0/#all/' + t.getId()
      ]);
    });
  });
  sheet.clear().getRange(1,1,rows.length,rows[0].length).setValues(rows);
}

Export Emails from Outlook to Excel

1. Use the Export to CSV Method in Outlook:

  • Navigate to File > Open & Export > Import/Export.
  • Choose Export to a file and select Comma Separated Values (CSV).
  • Select the email folder you want to export from (e.g., Inbox).
  • When prompted, click Map Custom Fields to select only the specific email attributes you need, such as FromToSubjectReceived Date, etc.
  • Complete the export and open the CSV in Excel to view just the metadata.

2. Filter and Copy Text-Based Metadata in Outlook:

  • Create a custom view in Outlook with only the desired columns visible (like sender, date, etc.).
  • Select the emails, copy, and then paste into Excel.
  • This method can be quicker for small batches, especially if you’re only exporting specific header info or metadata.

3. Use Power Query for Dynamic Export:

  • Power Query in Excel can connect directly to Outlook and filter only the required fields.
  • This method allows ongoing updates and automation while keeping the data minimal.
  1. Open Excel and go to the Data tab.
  2. Select Get Data > From Other Sources > From Microsoft Exchange.
  3. Enter your Outlook email address and sign in to connect.
  4. Choose the mailbox folder (e.g., Inbox) containing the emails you want.
  5. In Power Query Editor, select only the columns you need, such as Subject, From, To, and DateReceived.
  6. Apply any filters to narrow down emails, like by date or sender.
  7. Click Close & Load to import the filtered email data into an Excel table.
  8. Refresh the query anytime to update your data with new or changed emails.

Note: we plan having this built within Actor, as an email app. Currently we’re exploring interest.

Note: exporting to Excel vs Google Spreadsheets doesn’t make any difference. Both are great tools, built by Google and Microsoft.

Now you’ve got your emails in a spreadsheet – ready to analyze, filter, or share. If you need this regularly you will need some sort of automation of doing it repetitively, at your desired intervals.

Hi, I’m ACTOR, designed to simplify life for busy professionals like you.

My mission is to be the best digital partner you’ve ever had—whether that’s keeping your schedule on track, managing your emails, or helping you focus on what truly matters.

Videos: getting started

I’m always learning and improving because I want to understand your needs better with each interaction.

Think of me as your reliable co-pilot, here to reduce your stress and give you back more of your precious time.
Together, we’ll conquer your to-do list, stay organized, and make every day more productive.

Let me handle the small stuff so you can focus on the big picture. Ready to make your day smoother? Let’s get started!

Try me out here