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 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-tnef

v1.4.0

Published

TNEF Parser using NodeJS

Downloads

1,798

Readme

node-tnef

NodeJS project that will parse Transport Neutral Encapsulation Format (TNEF) files and extract any attachments from the files. This is useful for people who do not have a Microsoft created email client but receive email attachments from people who are using an email client like Outlook.

Based on the GO project: https://github.com/Teamwork/tnef

What are TNEF files?

Read here for more information: https://en.wikipedia.org/wiki/Transport_Neutral_Encapsulation_Format

In a nutshell, the TNEF format was created by Microsoft as a proprietary format for sending Rich Text Format emails and attachments. Unfortunately, those who are using email clients that are not created by Microsoft(so, not Outlook or Exchange) cannot open these emails/attachments. Most TNEF files are named winmail.dat but other names are common as well such as win.dat and Part 1.2

How to Install

To install globally: npm install node-tnef -g

To install to your local folder: npm install node-tnef

How to Use as a Console application

Run: node-tnef --help for a condensed outline of how to use the command line application

node-tnef can parse entire directories or just single files.

If you are attempting to parse an entire directory of files, find or create the directory that contains the TNEF files you wish to parse. Once you've identified the directory, run: node-tnef parse <path to your TNEF files> or node-tnef parse -d <path to your TNEF files> or node-tnef parse --directory <path to your TNEF files>

If you are attempting to parse just a single file, find the file that is the supposed TNEF file you wish to parse. Once you've identified the file, run: node-tnef parse -f <path to your TNEF file> or node-tnef parse --file <path to your TNEF file>

The TNEF parser will enumerate every file in the directory. If the file does not contain the TNEF signature, it will output to the console and move to the next file. If the file contains the TNEF signature, the parser will extract the attachment contents and write them to the new folder <path to your TNEF files>/processed.

How to use within a NodeJS project

Just require in node-tnef into a NodeJS project. The node-tnef library currently has a parse method that:

  • takes a path to a TNEF formatted file
  • a callback function which returns a Buffer containing the decoded TNEF content

There is also a parseBuffer method that:

  • takes a Buffer representation of the TNEF file
  • a callback function which returns a Buffer containing the decoded TNEF content

Object Properties:

  • Title - The attachment's title(including file extension)
  • Data - The attachment data. Can be used to write to a file using fs or another mechanism. Create a new Buffer passing in Data.

Examples:

var tnef = require('node-tnef')
var fs = require('fs')
var path = require('path')

tnef.parse('/path/to/the/tnef/file', function (err, content) {
    // here you could write the data to a file for example
    var firstAttachment = content[0]
    fs.writeFile(path.join(aPath, firstAttachment.Title), new Buffer(firstAttachment.Data), (err) => {
        console.log('success!')
    })
    ...
})

tnef.parseBuffer([your buffer of data], function (err, content) {
    // content would contain the result data as a Buffer
    // from here you can write to a file, evaluate the contents(ex. content.Attachments or content.Body)
})

Issues/Feedback?

Create an issue at this repo and I will try my best to fix the problem or implement the suggestion.