msgparser

package module
v1.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2024 License: GPL-3.0 Imports: 13 Imported by: 0

README

outlook-msg-parser

A Go library to parse .msg files from Microsoft Outlook.

This library is designed to handle various MAPI properties and extract relevant information from .msg files. It supports different versions and implementations of the MAPI standard, ensuring compatibility with a wide range of .msg files.

Features

  • Parse plain text and HTML bodies of messages
  • Extract email headers, subject, sender, recipients (To, CC, BCC)
  • Handle attachments separately
  • Support for multiple MAPI property tags
  • Compatibility with different versions of Microsoft Outlook

Mentions to the original developer

I created this refactored version to clean the code, added further support to more version of the .msg files, new format types, logging, test and examples. Orinally from https://github.com/oucema001/OutlookMessageParser-Go

Installation

To install the library, use go get:

go get github.com/willthrom/outlook-msg-parser


##  Usage

```sh
Here is an example of how to use the library to parse a .msg file:

package main

import (
    "log"
    "os"

    "github.com/willthrom/outlook-msg-parser"
)

func main() {
    // Open the .msg file
    file, err := os.Open("path/to/your/file.msg")
    if err != nil {
        log.Fatalf("Failed to open file: %v", err)
    }
    defer file.Close()

    // Parse the .msg file
    msg, err := OutlookMessageParser.ParseMsgFile(file)
    if err != nil {
        log.Fatalf("Failed to parse file: %v", err)
    }

    // Print the parsed message
    log.Printf("Parsed Message: %+v", msg)
}

Documentation

Index

Constants

View Source
const PropertyStreamPrefix = "__substg1.0_"

PropertyStreamPrefix is the prefix used for a property stream in the msg binary

View Source
const PropsKey = "__properties_version1.0"
View Source
const RecepientStreamPrefix = "__recip_version1.0_"
View Source
const ReplyToRegExp = "^Reply-To:\\s*(?:<?(?<nameOrAddress>.*?)>?)?\\s*(?:<(?<address>.*?)>)?$"

ReplyToRegExp is a regex to extract the reply to header

Variables

This section is empty.

Functions

func ParseMsgFile added in v1.1.1

func ParseMsgFile(file string) (res *models.Message, err error)

ParseMsgFile parses the msg file and sets the properties

func ParseMsgFileWithDebug added in v1.1.1

func ParseMsgFileWithDebug(file string) (res *models.Message, err error)

ParseMsgFileWithDebug parses the msg file with debug information

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳