Skip to content

uponusolutions/tnef

 
 

Repository files navigation

Go GoDoc CodeQL

With this library you can extract the body and attachments from Transport Neutral Encapsulation Format (TNEF) files.

This work is based on https://github.com/koodaamo/tnefparse, http://www.freeutils.net/source/jtnef/, https://github.com/teamwork/tnef and https://github.com/verdammelt/tnef.

Example usage

package main

import (
	"os"

	"github.com/uponus/tnef"
)

func main() {
	t, err := tnef.DecodeFile("./winmail.dat")
	if err != nil {
		return
	}
	wd, _ := os.Getwd()
	for _, a := range t.Attachments {
		os.WriteFile(wd+"/"+a.Title, a.Data, 0777)
	}

	htmlBody, found := tnef.AttributeByMAPIName(t.MAPIAttributes, tnef.MAPIBodyHTML)
	if found {
		os.WriteFile(wd+"/bodyHTML.html", htmlBody.Data, 0777)
	}

	txtBody, found := tnef.AttributeByMAPIName(t.MAPIAttributes, tnef.MAPIBody)
	if found {
		os.WriteFile(wd+"/bodyTxt.html", txtBody.Data, 0777)
	}
}

About

Go library to extract body and attachments from TNEF files

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 99.1%
  • Makefile 0.9%