Emailens
Engine Package

Transform

Transform HTML emails for specific email clients with per-client CSS rewriting.

transformForAllClients

Transforms HTML for all 10 supported email clients.

function transformForAllClients(html: string): TransformResult[]

Parameters

ParameterTypeDescription
htmlstringThe email HTML source code

Returns

An array of TransformResult objects, one per client:

interface TransformResult {
  clientId: string;       // e.g. "gmail-web"
  html: string;           // Transformed HTML for this client
  warnings: CSSWarning[]; // Warnings specific to this transform
}

Example

import { transformForAllClients } from "@emailens/engine";

const results = transformForAllClients(emailHtml);

for (const result of results) {
  console.log(`${result.clientId}: ${result.warnings.length} warnings`);
  // Write transformed HTML to file, render in iframe, etc.
}

transformForClient

Transform HTML for a single email client.

function transformForClient(html: string, clientId: string): TransformResult

Parameters

ParameterTypeDescription
htmlstringThe email HTML source code
clientIdstringClient ID (e.g. "gmail-web", "outlook-windows", "outlook-windows-legacy")

Example

import { transformForClient } from "@emailens/engine";

const result = transformForClient(emailHtml, "outlook-windows-legacy");
console.log(result.html); // HTML rewritten for Outlook Classic (Word engine)

What transforms do

Transforms rewrite CSS for each client's rendering engine:

  • Style inlining — moves <style> block rules to inline style attributes (for Gmail)
  • Property removal — strips CSS properties the client doesn't support
  • Fallback insertion — adds client-specific fallbacks (e.g., VML for Outlook)
  • Value conversion — adjusts units and values for client compatibility
  • Media query handling — removes or adjusts media queries based on client support

On this page