npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

html-to-oft

v0.1.0

Published

Generate Outlook .oft template files from HTML in Node.js.

Readme

html-to-oft

Create Outlook .oft template files from HTML in Node.js.

html-to-oft generates CFB/OLE structured storage files with MAPI-style message streams, so templates can be created without Outlook, Windows COM automation, or platform-specific runtime dependencies.

Installation

npm install html-to-oft

Requires Node.js 18 or newer.

Usage

import { createOft } from 'html-to-oft';
import { writeFile } from 'node:fs/promises';

const oft = await createOft({
  subject: 'Newsletter',
  html: `
    <table role="presentation" width="600" cellpadding="0" cellspacing="0">
      <tr>
        <td>
          <img src="https://example.com/header.png" width="600" alt="">
        </td>
      </tr>
    </table>
  `,
});

await writeFile('newsletter.oft', oft);

API

createOft(input)

Creates an Outlook template and returns a Buffer.

const oft = await createOft({
  subject: 'Promo',
  html: '<h1>Hello</h1>',
  text: 'Hello',
  to: ['[email protected]'],
  cc: [{ email: '[email protected]', name: 'Manager' }],
});

Input fields:

| Field | Description | | --- | --- | | html | Required HTML body. | | subject | Message subject. | | text | Plain-text body. Generated from HTML when omitted. | | from | Sender metadata. | | recipients | Explicit recipient list. | | to, cc, bcc | Recipient shortcuts. | | attachments | Binary attachments. |

Attachments

const oft = await createOft({
  subject: 'With attachment',
  html: '<p>See attached.</p>',
  attachments: [
    {
      filename: 'document.pdf',
      content: pdfBuffer,
      mimeType: 'application/pdf',
    },
  ],
});

Inline attachments can be referenced with cid and inline.

const oft = await createOft({
  subject: 'Inline image',
  html: '<img src="cid:image001.png@example" width="600" alt="">',
  attachments: [
    {
      filename: 'image001.png',
      content: pngBuffer,
      mimeType: 'image/png',
      cid: 'image001.png@example',
      inline: true,
    },
  ],
});

patchOftTemplate(baseOft, input)

Updates known subject, body, and HTML streams in an existing template.

import { patchOftTemplate } from 'html-to-oft';

const patched = await patchOftTemplate(existingOft, {
  subject: 'Updated subject',
  html: '<h1>Updated</h1>',
  text: 'Updated',
});

inspectOft(buffer)

Reads a template and returns a structural summary.

import { inspectOft } from 'html-to-oft';

const info = inspectOft(oft);

console.log(info.hasHtml);
console.log(info.attachmentCount);

HTML Helpers

import { htmlToText, normalizeHtml } from 'html-to-oft';

normalizeHtml(html) prepares HTML for Outlook-oriented template generation.

htmlToText(html) creates a plain-text fallback from HTML.

CLI

html-to-oft ./email.html --subject "Promo" --to [email protected] --out promo.oft
oft-dump ./promo.oft

Compatibility

The generated files are designed for Outlook .oft workflows. Outlook rendering can vary between Outlook versions, especially around HTML tables and inline images, so templates should be checked in the target Outlook client.

License

MIT