DEV Community

bulldo.gs
bulldo.gs

Posted on

A 722-byte HTML email with all 1,200 dispatch rows attached

The last line of our fictional dispatch table was the one a shift lead needed on Monday: 5,400 units across 1,200 dispatches, with two rows to review. We put it under the table. That produced 189,633 bytes of HTML before the mail reader had to do anything with it.

Gmail can put the end of a long message behind View entire message. An MJML author ran into clipping on their generated templates. Mailchimp describes a threshold around 102 KB. You can measure the body you generate. The recipient’s actual inbox is where you check whether Gmail clipped it.

We kept the same dispatch ledger and made two messages:

From the same Google Sheets rows Full table Summary and attachment
Decoded HTML body 189,633 bytes 722 bytes
Dispatch units 5,400 5,400
Exceptions in the email Find them among 1,200 rows D-0004 and D-1200
Where to find the complete ledger Email body 1,200-row CSV

The summary opens with the total, then gives the dispatch ID, site and units for each exception. The first needs a check on 4 units in Osaka. The other is the last row of the sheet, 8 units in Osaka. That last row still has to make it into the recipient’s file.

Measure the HTML you will actually send

If you construct the body in Apps Script, measure its UTF-8 bytes after assembling the HTML. Repeating inline styling in every cell counts. A location like São Paulo also takes more UTF-8 bytes than its JavaScript string length suggests.

function htmlByteCount(htmlBody) {
  return Utilities.newBlob(htmlBody, 'text/html').getBytes().length;
}
Enter fullscreen mode Exit fullscreen mode

The complete compact message in this example is 50,924 bytes on disk. That includes the plain-text version, encoded CSV and MIME headers. Its 722-byte HTML body answers a different question.

Try the recipient’s side

Open the weekly dispatch email exercise. Select 1,200 rows, download the summary message and open the .eml in a desktop mail reader. Save dispatch-ledger.csv and check the last row. In Mutt 2.2.12 the plain-text message displayed both exceptions. The attachment we saved had all 1,200 dispatch IDs, in order, including D-1200.

Change the ledger to 24 rows and compare the two sizes again. You can also copy four tab-separated columns from a spreadsheet into the local exercise. It generates the two files on your device. The samples use fictional addresses and send no mail.

Top comments (0)