node-tnef is a Node.js library designed to parse Transport Neutral Encapsulation Format (TNEF) files, commonly encountered as `winmail.dat` attachments in emails. This proprietary Microsoft format is often sent by Outlook users but is not natively understood by other email clients. The library extracts embedded content and attachments from these files, addressing a niche but persistent interoperability problem. It offers both a command-line interface for direct file or directory parsing and a programmatic API for use within Node.js projects, primarily through its `parse` (for file paths) and `parseBuffer` (for in-memory buffers) methods. The current stable version is 1.4.0. The package maintains an ad-hoc release cadence, focusing on bug fixes and feature enhancements, such as the addition of `parseBuffer` in version 1.3.0 and the removal of the `bluebird` dependency in 1.4.0.
npm install node-tnefVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to use `tnef.parseBuffer` to process an in-memory TNEF buffer and extract its contents, including writing an attachment to a file.
Use Node.js's `util.promisify` to convert the callback-based methods into Promise-returning functions if `async/await` is desired, or adhere to the callback pattern.
If your project implicitly relied on `bluebird` through `node-tnef`, explicitly install `bluebird` as a direct dependency or migrate to native Promises where appropriate. The library itself now uses native Node.js asynchronous patterns.
Before passing files to `tnef.parse`, consider pre-validating their content or implementing custom error handling in your callback to differentiate between actual parsing failures and non-TNEF files.
For `node-tnef` v1.4.0 and later, `bluebird` is no longer a dependency. If your project still requires `bluebird`, install it explicitly: `npm install bluebird`.
Ensure you are using the CommonJS `require` syntax and accessing methods as properties: `const tnef = require('node-tnef'); tnef.parse(...);`Always provide a callback function in the format `(err, content) => { ... }` as the second argument to `tnef.parse` and `tnef.parseBuffer`.Verify that the file you are attempting to parse is indeed a TNEF-encoded file (e.g., typically named `winmail.dat`). The library will skip non-TNEF files without throwing a programmatic error, but logs this message to the console.
No dependency data recorded yet.