Package: tnefparse
tnefparse - TNEF decoding and attachment extractionThis is a pure-python library for decoding Microsoft’s Transport Neutral Encapsulation Format (TNEF), for Python
versions 3.6+ and PyPy3. The last version to support Python2 was 1.3.1. For more information on TNEF, see for examplewikipedia. The full TNEF specification
is also available as aPDF download.Atnefparsecommand-line utility is provided for listing contents of TNEF files, extracting attachments
found inside them and so on:usage: tnefparse [-h] [-o] [-a] [-p PATH] [-b] [-hb]
                 [-l LEVEL] [-c]
                 file [file ...]

Extract TNEF file contents. Show this help message if no arguments are given.

positional arguments:
  file                  space-separated list of paths to the TNEF files

optional arguments:
  -h, --help             show this help message and exit
  -o, --overview         show (possibly long) overview of TNEF file contents
  -a, --attachments      extract attachments, by default to current dir
  -z, --zip              extract attachments into a single zip file, by default to current dir
  -p PATH, --path PATH   optional explicit path to extract attachments to
  -b, --body             extract the body to stdout
  -hb, --htmlbody        extract the HTML body to stdout
  -rb, --rtfbody         extract the RTF body to stdout
  -l LEVEL, --log LEVEL  set log level to DEBUG, INFO, WARN or ERROR
  -c, --checksum         calculate checksums (off by default)
  -d, --dump             extract a json dump of the tnef contentsThe library can also be used as a basis for applications that need to parse TNEF. To parse a TNEF attachment, run eg. :>>> from tnefparse import TNEF
>>> with open("tests/examples/one-file.tnef", "rb") as tneffile:
...    tnefobj = TNEF(tneffile.read())The parsed attachment contents are then available as TNEF object attributes:signature - TNEF file signaturekey - generated by TNEF enabled transports before using the TNEF implementation to generate a TNEF streamcodepage - a Windows code page stringobjects - a collection ofTNEFObjectinstancesattachments - a collection ofTNEFAttachmentinstancesmapiprops - a collection of MAPI properties represented byTNEFMAPI_Attributeinstancesbody - message body (may contain both HTML and RTF)htmlbody - a string containing just the HTML message bodyrtfbody - just the RTF bodySome of the above properties may be empty, depending on what’s contained in the attachment that was parsed.TestsTo run the test suite, all you need istox.toxwill run all tests on all supported Python versions.If you want to run the tests only for e.g. Python 3.8, just entertox -e py38.You also can run a subset of tests in a specific environment by invoking e.g.tox -e py38 – -k test_cmdline.Withtox -e coverageyou can generate a coverage report.
The output will be shown in the terminal and a HTML coverage report will be generated in thehtmlcovdirectory.ContributingIssues and pull requests welcome.Please however always provide an example TNEF filethat can be used to demonstrate the bug or desired behavior, if at all possible.Note: If you have understanding of TNEF and/or MIME internals or just need this package and want to help with maintaining it, I am open to giving you commit rights. Just let me know.tnefparse 1.4.0 (2021-01-24)drop Python 2 supportdrop Python 3.5 support (jugmac00)add Python 3.9 support (jugmac00)command-line support for zipped export of attachments (Beercow)introduce using type annotations (jugmac00)remove deprecated parseFile & raw_mapi functionsfix str representation for TNEF class (jugmac00)prefergetattrovereval(eumiro)fixtest_zipdeprecation warning for bytes (1nF0rmed)correctly handle attachments of embedded objects (jrideout)add expirimental support for parsing embedded message objects (jrideout)zipped output now uses long filename when possible (jrideout)run GitHub Actions CI for pull requests and once a week (eumiro)use pathlib instead of os.path (eumiro)change logger name for mapi to the package name (jrideout)add unit tests for mapi attribute parsing (jrideout)do not use Travis CI any more (jugmac00)tnefparse 1.3.1 (2020-09-30)heuristics to decode binary body and filenames when possible (jrideout)JSON export for TNEF contents tnefparse (jrideout)add support for Python 3.8 (jugmac00)modernize package and test setup (jugmac00)apply Flake8 on the code and enforce rules on CI (jugmac00)tnefparse 1.3.0 (2018-12-01)drop Python 2.6 & 3.3 supportPython 2/3 compatibility fixesmore tests & example files (jrideout)overall improved testing & start tracking coveragelots of parsing improvements (jrideout)turn some unnecessary warnings into debug messagesadd tnefparse -p | –path option for setting attachment extraction pathsupport more MAPI (PidTag) properties (jrideout)support RTF body extraction (jrideout)support extracting top level object attributes in msgprops (jrideout)util.raw_mapi & tnefparse.parseFile functions will be deprecated after 1.3tnefparse 1.2.3, 2018-11-14misc. fixestnefparse 1.2.2, 2017haveTNEFinit raise ValueError on invalid TNEF signature, rather than calling sys.exit()parseFileconvenience function should not expect aselfparameter, removedother misc. fixestnefparse 1.2.1, 2013Python 3 compatibility; tests pass on Python 2.6/2.7/3.2/3.3add package to travis ciadd tox.ini for testing usinghttps://testrun.org/toxtnefparse 1.2, 2013performance improvements & bug fixes (Dave Baggett)added to_zip function for converting TNEF attachments into ZIPped ones (Dave Baggett)tnefparse is now used in the inky email client from Arcodetnefparse 1.1.1, 08/2012 (unreleased)fixed entry point bug that caused ‘tnefparse’ cmd-line invocation to failtnefparse 1.1, 03/2012Repackaged and renamed the libraryCode moved to githubUse the stdlib logging moduleFurther bug fixes and enhancements to pure-python codeAdd a command-line scriptDrop the unix tnef command-line tool wrapperpytnef 0.2.1-Novell, circa 2010Bug fixes/enhancements to pure-python code (Tom Doman)pytnef 0.2, circa 2005Added a wrapper for the unix tnef command-line tool (Petri Savolainen)Pure-python code not very useful yetpytnef 0.1 - circa 2005First version (pure-python) created as a conversion of a Ruby TNEF decoder
by Trevor Scheroeder (Petri Savolainen)