Skip to content

Diagnostic reference

Limit Exceeded: Email Body Size / Recipients Per Message

Fix Exception: Limit Exceeded: Email Body Size and Email Recipients Per Message in Google Apps Script MailApp and GmailApp by batching and attaching files.

Updated December 6, 2026

Apps Script error

Exception: Limit Exceeded: Email Body Size.

What it means

MailApp and GmailApp cap email bodies at 200 KB per message on consumer Google accounts (400 KB on Google Workspace), total attachments at 25 MB per message, and recipients at 50 per message for both consumer and Workspace accounts (subject to daily recipient quotas). Building an inline HTML table from hundreds of spreadsheet rows or joining an entire mailing list into bcc triggers these limits.

Related error messages

  • Exception: Limit Exceeded: Email Recipients Per Message.
  • Exception: Limit Exceeded: Email Total Attachments Size.
  • Exception: Limit Exceeded: Email Attachment Size.

Before and after

The code before and after the fix.

Problem 7 changed lines
function sendWeeklyUpdate(recipients, htmlTable) {
  // Fails when recipients exceeds 50 per message or htmlTable exceeds 200 KB.
  MailApp.sendEmail({
    to: 'team@example.com',
    bcc: recipients.join(','),
    subject: 'Weekly update',
    htmlBody: htmlTable,
  });
}
Fixed 18 changed lines
function sendWeeklyUpdate(recipients, htmlTable) {
  const BATCH_SIZE = 45;
  const attachment = Utilities.newBlob(htmlTable, 'text/html', 'weekly-update.html');
  const useAttachment = Utilities.newBlob(htmlTable).getBytes().length > 180 * 1024;

  for (let i = 0; i < recipients.length; i += BATCH_SIZE) {
    const batch = recipients.slice(i, i + BATCH_SIZE);
    // Count the To address plus every BCC recipient against the daily quota.
    if (MailApp.getRemainingDailyQuota() < batch.length + 1) {
      throw new Error('Daily email quota reached before batch ' + i + '.');
    }
    MailApp.sendEmail({
      to: 'team@example.com',
      bcc: batch.join(','),
      subject: 'Weekly update',
      body: useAttachment ? 'See the attached HTML report.' : 'See the HTML report below.',
      ...(useAttachment ? { attachments: [attachment] } : { htmlBody: htmlTable }),
    });
  }
}

How to fix it

  • Split recipient lists into chunks of 50 or fewer per message (counting to, cc, and bcc together) and check MailApp.getRemainingDailyQuota() before each send.
  • Check Utilities.newBlob(htmlBody).getBytes().length before sending; when a report approaches 200 KB, send it as an HTML/PDF attachment or a Drive link instead of inline htmlBody.
  • Avoid base64-inlining large images inside htmlBody; attach them via inlineImages or link to Drive.

Things to check

  • Daily recipient quotas are 100/day on consumer Google accounts and 1,500/day on Google Workspace accounts, counted per recipient across to, cc, and bcc.
  • myFunction flags messages that statically exceed 50 recipients or 200 KB bodies before execution.

In the Apps Script editor

Catch errors like this before clicking Run.

myFunction (published as Error Checker for Google Apps Script on the Chrome Web Store) checks your code while you edit at script.google.com. Diagnostics, autocomplete, and rule-based quick fixes are free without an account, run in your browser, and request no Google Drive, Gmail, or Apps Script project OAuth scopes. Writing Apps Script with an AI coding agent? Connect the Apps Script MCP server to run the same static checks before pasting code.