TNEF(1)

πŸ’– TNEF(1) β€” the tnef filter, explained by your favorite Unix bestie πŸ’–

okay so. you've got one of those cursed Microsoft email attachments and it's just... sitting there. not opening. girl, I got you. this is the General Commands Manual page for tnef, and we're gonna unpack the whole thing together 🫢


✨ NAME ✨

tnef β€” decode Microsoft's Transport Neutral Encapsulation Format. yes that's a real thing, no I'm not making it up πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

tnef [options] [FILE]

tnef {--help | --version}

🌸 DESCRIPTION 🌸

This page documents the tnef filter, bestie. So tnef decodes e-mail attachments that are encoded in Microsoft's Transport Neutral Encapsulation Format (from here on out we're calling it TNEF, because saying the whole thing every time is exhausting). Basically TNEF "wraps" Microsoft e-mail attachments. It's giving ✨mystery gift✨ but make it unusable.

And here's the tea: those "wrapped" attachments are literally inaccessible to any e-mail client that doesn't understand TNEF. Like, locked out. πŸ’€ But good news!! The tnef filter can be used by any MIME-aware client to unpack these attachments. we love a savior moment πŸ‘‘


πŸ’… OPTIONS πŸ’…

  • -f FILE, --file=FILE β€” use FILE as the input. if you pass - that means stdin, iconic. When you don't use this option at all, tnef just reads the data from stdin anyway. no pressure.
  • -C DIR, --directory=DIR β€” unpack the file attachments into DIR. cute little home for them πŸŽ€
  • -x SIZE, --maxsize=SIZE β€” caps the maximum size of the extracted archive, measured in bytes. a lil boundary, we respect it.
  • -t, --list β€” list the attached files, do not extract. For every file in the datafile, the file name and the full path get printed. just a lil peek, no touching πŸ™ˆ

If the verbose option is also provided then this option acts as the --list-with-mime-types option, and it also prints the file length (in bytes) and the date of the file, before the other data. so you get the whole picture, front to back.

  • --list-with-mime-types β€” same as the list option but it also prints the MIME type and content ID of each file, after the filename and file path. extra detail, extra slay.
  • -w, --interactive, --confirmation β€” ask for confirmation for every single action. yes ma'am, consent checks only 🫢
  • --overwrite β€” when extracting attachments, overwrite existing files. bold. fearless. lowkey terrifying.
  • --number-backups β€” when extracting attachments, if the file FOO is about to be overwritten, create FOO.n instead. the way it just... numbers them 😭
  • --use-paths β€” honor the file pathnames specified in the TNEF attachment. ⚠️ heads up bestie: for security reasons, paths to attached files are ignored by default. this flag turns that safety off, so know what you're doing.
  • --save-body FILE β€” save the message body data found in the TNEF data. By default tnef only extracts the attached files and not the message body. There can be up to three message bodies in the file: plain text, HTML encoded, and RTF encoded. Which ones get saved is specified by the --body-pref option. By default the message bodies are written to a file named message with an extension based upon the type (txt, html, rtf).
  • --body-pref PREF β€” specifies which of the possibly three message body formats will be saved. PREF can be up to three characters long, and each character must be one of 'r', 'h', or 't', specifying RTF, HTML or text. The order is the order that the data will be checked, and the first type found will be saved. If PREF is the special value of 'all' then any and all message body data found will be saved. The default is 'rht'. choose your own adventure ✨
  • --save-rtf FILE β€” DEPRECATED. Equivalent to --save-body=FILE --body-pref=r. it's giving legacy, we still list it tho πŸ’€
  • -h, --help β€” show the usage message. everybody's favorite.
  • -V, --version β€” display version and copyright.
  • -v, --verbose β€” produce verbose output. spill everything πŸ—£οΈ
  • --debug β€” enable debug output. (This will produce a very large amount of output.) like, genuinely a lot. do not say I didn't warn you.

⚠️ KNOWN LIMITATIONS ⚠️

tnef ignores the OEMCodePage data in the data file. It assumes Unicode data. that's the whole limitation, periodt.


🌈 EXAMPLE 🌈

The following example demonstrates typical tnef usage with a popular Unix mail client called "mutt". let's walk through it together, step by step 🧚

⭐ Step 1 β€” Configure ~/.mailcap

Mutt can't use tnef for its intended purpose until an appropriate content type definition exists in ~/.mailcap. Here's a sample definition:

application/ms-tnef; tnef -w %s

This mailcap entry says that whenever the MIME content type:

application/ms-tnef

is encountered, use this command to decode it:

tnef -w %s

The latter command string invokes tnef, specifying both the -w option and the attachment (created as a temporary file) as command line arguments. chef's kiss 🀌

⭐ Step 2 β€” Add The Filter To $PATH

Mutt can't invoke tnef if the filter isn't accessible via $PATH. no path, no party.

⭐ Step 3 β€” Test Mutt

Use mutt to read a message that includes a TNEF attachment. Mutt will note that an attachment of type "application/ms-tnef is unsupported".

Press the "v" key to open mutt's "view attachment" menu.

Move the cursor over the TNEF attachment and press the enter key to "view" the attachment. Mutt will launch tnef and invoke it using the command line syntax specified in ~/.mailcap (step 1). tnef then decodes all file(s) included in the TNEF attachment, prompting for confirmation prior to creating an individual file (refer to the -w option above). -w is useful here because it gives the end user a chance to view the file name(s) included in the mail message. love that for us πŸ’–

ngl, Mutt's attachment menu also supports a pipe option, which permits the user to pipe attachments to an external filter (how convenient). So, to list the contents of a TNEF attachment prior to decoding it, press the "|" key and enter this command:
tnef -t

πŸ‘€ SEE ALSO πŸ‘€

metamail(1), mailcap(4), mutt(1), other email clients.


🫢 AUTHOR 🫢

Mark Simpson <verdammelt@gmail.com>


πŸ› REPORTING BUGS πŸ›

Please report issues via this project's issue tracker on GitHub: https://github.com/verdammelt/tnef/issues


πŸ“š OTHER REFERENCES πŸ“š

This web page:

https://www.dwheeler.com/essays/microsoft-outlook-tnef.html

describes how to configure Microsoft email clients so that the TNEF format is disabled when sending messages to non-TNEF-compatible clients. go read it, it's a whole vibe ⭐


and that's the whole page bestie!! this was the TNEF(1) page straight out of the General Commands Manual β€” same name up top, same name at the bottom, no notes πŸ’…βœ¨ mwah πŸŽ€