{"id":22467,"library":"tnefparse","title":"tnefparse","description":"tnefparse is a pure Python library for decoding TNEF (Transport Neutral Encapsulation Format) files, commonly used by Microsoft Outlook to encapsulate rich email content. Version 1.4.0 is the latest release, with no external dependencies. It has a low release cadence.","status":"active","version":"1.4.0","language":"python","source_language":"en","source_url":"https://github.com/koodaamo/tnefparse","tags":["tnef","email","outlook","winmail.dat","decoding"],"install":[{"cmd":"pip install tnefparse","lang":"bash","label":"Standard install"}],"dependencies":[],"imports":[{"note":"TNEF is the main class, not a module.","wrong":"import tnefparse.TNEF","symbol":"TNEF","correct":"from tnefparse import TNEF"},{"note":"Attachment class for accessing file data.","symbol":"TNEFAttachment","correct":"from tnefparse import TNEFAttachment"}],"quickstart":{"code":"import os\nfrom tnefparse import TNEF\n\nwith open('winmail.dat', 'rb') as f:\n    data = f.read()\ntnef = TNEF(data)\nprint('Attachments:', len(tnef.attachments))\nfor att in tnef.attachments:\n    print('Name:', att.name)\n    if att.name:\n        with open(att.name.lstrip('/'), 'wb') as out:\n            out.write(att.data)","lang":"python","description":"Open a TNEF file (often winmail.dat) and list attachments."},"warnings":[{"fix":"Use os.path.basename() or att.name.lstrip('/') when writing files.","message":"Attachment names may include leading slash from Unix path; strip it before saving to avoid writing to root.","severity":"gotcha","affected_versions":"all"},{"fix":"Use tnef.attachments instead of tnef.files.","message":"The old method 'tnef.files' was deprecated in favor of 'tnef.attachments'.","severity":"deprecated","affected_versions":"<1.3"},{"fix":"Open file in binary mode ('rb') or call .encode() on string.","message":"TNEF data passed to constructor must be bytes, not string. Decoding first will cause TypeError.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Open the file in binary mode: with open('winmail.dat', 'rb') as f: data = f.read()","cause":"Passing a string instead of bytes to TNEF constructor.","error":"TypeError: a bytes-like object is required, not 'str'"},{"fix":"Use 'tnef.attachments' instead of 'tnef.files'.","cause":"Using deprecated 'files' attribute in newer versions (>=1.3).","error":"AttributeError: 'TNEF' object has no attribute 'files'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}