a TNEF decoding library written in python, without external dependencies
Project description
tnefparse - TNEF decoding and attachment extraction
This is a pure-python library for decoding Microsoft’s Transport Neutral Encapsulation Format (TNEF), for Python versions 2.7, 3.5+ and PyPy. For more information on TNEF, see for example wikipedia. The full TNEF specification is also available as a PDF download.
A tnefparse
command-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 -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)
The 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 signature
key - generated by TNEF enabled transports before using the TNEF implementation to generate a TNEF stream
codepage - a Windows code page string
objects - a collection of TNEFObject instances
attachments - a collection of TNEFAttachment instances
mapiprops - a collection of MAPI properties represented by TNEFMAPI_Attribute instances
body - message body (may contain both HTML and RTF)
htmlbody - a string containing just the HTML message body
rtfbody - just the RTF body
Some of the above properties may be empty, depending on what’s contained in the attachment that was parsed.
Use python setup.py test
to run the tests.
Issues and pull requests welcome. Please however always provide an example TNEF file that 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.3.0 (2018-12-01)
drop Python 2.6 & 3.3 support
Python 2/3 compatibility fixes
more tests & example files (jrideout)
overall improved testing & start tracking coverage
lots of parsing improvements (jrideout)
turn some unnecessary warnings into debug messages
add tnefparse -p | –path option for setting attachment extraction path
support more MAPI (PidTag) properties (jrideout)
support RTF body extraction (jrideout)
support extracting top level object attributues in msgprops (jrideout)
util.raw_mapi & tnefparse.parseFile functions will be deprecated after 1.3
tnefparse 1.2.3, 2018-11-14
misc. fixes
tnefparse 1.2.2, 2017
have TNEF init raise ValueError on invalid TNEF signature, rather than calling sys.exit()
parseFile convenience function should not expect a self parameter, removed
other misc. fixes
tnefparse 1.2.1, 2013
Python 3 compatibility; tests pass on Python 2.6/2.7/3.2/3.3
add package to travis ci
add tox.ini for testing using https://testrun.org/tox
tnefparse 1.2, 2013
performance 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 Arcode
tnefparse 1.1.1, 08/2012 (unreleased)
fixed entry point bug that caused ‘tnefparse’ cmd-line invocation to fail
tnefparse 1.1, 03/2012
Repackaged and renamed the library
Code moved to github
Use the stdlib logging module
Further bug fixes and enhancements to pure-python code
Add a command-line script
Drop the unix tnef command-line tool wrapper
pytnef 0.2.1-Novell, circa 2010
Bug fixes/enhancements to pure-python code (Tom Doman)
pytnef 0.2, circa 2005
Added a wrapper for the unix tnef command-line tool (Petri Savolainen)
Pure-python code not very useful yet
pytnef 0.1 - circa 2005
First version (pure-python) created as a conversion of a Ruby TNEF decoder by Trevor Scheroeder (Petri Savolainen)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file tnefparse-1.3.0.tar.gz
.
File metadata
- Download URL: tnefparse-1.3.0.tar.gz
- Upload date:
- Size: 2.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 46be01e4176cdcd42b51abf0c145ff946fb1b25fb5c989c51f82675efcecdf69 |
|
MD5 | 5a54415a3a847fa8aca436b80d2f52af |
|
BLAKE2b-256 | a086998f8525aee2eabd134475015d2995cdf1c55f5c39c9b529656ae9647325 |
File details
Details for the file tnefparse-1.3.0-py3.7.egg
.
File metadata
- Download URL: tnefparse-1.3.0-py3.7.egg
- Upload date:
- Size: 44.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce3305c9c85b5d42534ce572267f8586d0cfe2d5c57fd63fc2209e3e05c66be7 |
|
MD5 | 2f0c9967caaee3b7ee508af30c9dbf2a |
|
BLAKE2b-256 | 40cdd491f41f9e0a0c949261f766e646fa9fa461161984724c859488b09d835f |
File details
Details for the file tnefparse-1.3.0-py3.6.egg
.
File metadata
- Download URL: tnefparse-1.3.0-py3.6.egg
- Upload date:
- Size: 44.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 065e7ad2b4949cda68db9f9286ac796f136396b06654d2a9dd790067a1ed59b3 |
|
MD5 | 847b0bbfe303cdb3c9a38b8078ad6ac4 |
|
BLAKE2b-256 | 1fcf3d61f8e69a0b1c60cb538eef033ccecec43c1aac0895bd0651c72a631802 |
File details
Details for the file tnefparse-1.3.0-py3.5.egg
.
File metadata
- Download URL: tnefparse-1.3.0-py3.5.egg
- Upload date:
- Size: 45.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e83ef45ce22b61c900d53ce57fd3031007c899f89a96943f838f2423d3d3a14b |
|
MD5 | bd6eaa083993f1adafecafe60a670f02 |
|
BLAKE2b-256 | 08c18555befb27fe59b55d37e296563f83722923a55848e4f3dbfac3a793cffd |
File details
Details for the file tnefparse-1.3.0-py3-none-any.whl
.
File metadata
- Download URL: tnefparse-1.3.0-py3-none-any.whl
- Upload date:
- Size: 24.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 47d793c7e63333dd99425c4d1b110900707a3b70d8f4193eee06cef322f93e28 |
|
MD5 | 5bbfe9d2eb0f3a5965d1dd4c3653d9d3 |
|
BLAKE2b-256 | abebd736cf5183c811622ef7d51b1be9f578b98f3a6b624c6de09d13095acbf9 |
File details
Details for the file tnefparse-1.3.0-py2.7.egg
.
File metadata
- Download URL: tnefparse-1.3.0-py2.7.egg
- Upload date:
- Size: 44.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | da061e0c893fc22f53d0597ec3b72dd8480f9372d841c60b6549582d7449043a |
|
MD5 | 917b048a8e37c7f2930f1b190fd61585 |
|
BLAKE2b-256 | beceafc22fb907985faf3e63f35c87e9e9880b487e51d874ba9d47432aa415c8 |
File details
Details for the file tnefparse-1.3.0-py2-none-any.whl
.
File metadata
- Download URL: tnefparse-1.3.0-py2-none-any.whl
- Upload date:
- Size: 24.3 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 86f001f05f32c1ee29429cab1f2c2d717ca5bb9b8dc1eb44dee09ae9ff028977 |
|
MD5 | a6b07bf55dee788388fcddcf7eaf9460 |
|
BLAKE2b-256 | e2f821176bdf1a4baa45c662fe0d2cfbb53bba66b3f4bb7bb710dd1391e98686 |