@sharpenednoodles/msg.reader-ts
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

MSG Reader TS

MSG Reader is an Outlook Item File (.msg) reader that is built with HTML5.

Allows to parse and extract necessary information (attachment included) from .msg file.

Based on original TypeScript conversion from here

Online demo

Angular service example

import { Injectable } from '@angular/core';
import * as MsgReader from '@sharpenednoodles/msg.reader-ts';
import { MSGFileData } from '@sharpenednoodles/msg.reader-ts';
import { Observable, of } from 'rxjs';

export class MsgParserService {
  constructor() { }

  parseMsg(msgFile: File): Observable<MSGFileData> {
    const fileReader = new FileReader();

    fileReader.readAsArrayBuffer(msgFile);

    return new Observable((observer) => {
      fileReader.onload = (e: ProgressEvent): void => {
        let bytes = new Uint8Array((<any>e.target).result);

        const msgReader = new MsgReader.MSGReader(bytes);
        const msg = msgReader.getFileData();

        if (msg['error']) { observer.error(msg['error']); }

        observer.next(msg as MSGFileData);
        observer.complete();
      }

      fileReader.onerror = (error: ProgressEvent): void => {
        observer.error(error);
      }
    });
  }
}

Fork

This project was orignally forked from:

https://github.com/ykarpovich/msg.reader

Package Sidebar

Install

npm i @sharpenednoodles/msg.reader-ts

Weekly Downloads

1,062

Version

0.1.2

License

APACHE

Unpacked Size

89.6 kB

Total Files

8

Last publish

Collaborators

  • sharpenednoodles