Recursive AI

Inspect email files from the command line

All onemail recipes

Install the onemail .NET tool and run onemail inspect on files or folders. Each message gets one line with its date, sender, subject, attachments and defects. Add --json for machine-readable output. It reads every format the library reads: .eml, .msg, .pst, .ost, mbox, Maildir, winmail.dat and Outlook Express .dbx.

Terminal
dotnet tool install -g RecursiveAI.OneMail.Cli --version 0.2.0-preview.2
onemail --version
Text
0.2.0-preview.2

The tool needs the .NET 10 runtime. The examples use public test files from Apache POI and Apache Tika:

Terminal
curl -LO https://raw.githubusercontent.com/apache/poi/REL_5_4_1/test-data/hsmf/attachment_test_msg.msg
curl -LO https://raw.githubusercontent.com/apache/poi/REL_5_4_1/test-data/hmef/quick-winmail.dat
curl -LO https://raw.githubusercontent.com/apache/tika/4.2.0/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-mail-module/src/test/resources/test-documents/complex.mbox
curl -LO https://raw.githubusercontent.com/apache/tika/4.2.0/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-mail-module/src/test/resources/test-documents/testRFC822_multipart_attachments.eml

One file

Terminal
onemail inspect attachment_test_msg.msg
Text
attachment_test_msg.msg: Msg
  #0  2009-04-22T14:36:33Z  from: Nicolas1 23456 <[email protected]>  subject: test pièce jointe 1  attachments: 2 (test-unicode.doc, pj1.txt)  defects: 0
inspected 1 files/stores, 1 items, 2 attachments, 0 defects (0 ambiguities), 0 not readable

The last line is a summary, written to standard error.

A folder, with attachment sizes

--sizes adds each attachment’s decoded size in bytes. A folder is searched for every file it can read:

Terminal
onemail inspect --sizes .
Text
./attachment_test_msg.msg: Msg
  #0  2009-04-22T14:36:33Z  from: Nicolas1 23456 <[email protected]>  subject: test pièce jointe 1  attachments: 2 (test-unicode.doc 24064B, pj1.txt 89B)  defects: 0
./complex.mbox: Mbox
  #0  2009-06-01T04:26:31Z  from: Jothi Padmanabhan <[email protected]>  subject: Re: question about when shuffle/sort start working  attachments: 0  defects: 0
  #1  2009-06-01T05:30:49Z  from: Jianmin Woo <[email protected]>  subject: Re: question about when shuffle/sort start working  attachments: 0  defects: 0
  #2  2009-06-01T06:03:13Z  from: Jothi Padmanabhan <[email protected]>  subject: Re: question about when shuffle/sort start working  attachments: 0  defects: 0
./quick-winmail.dat: Tnef
  #0  -  from: -  subject: -  attachments: 5 (quick.doc 19968B, quick.html 428B, quick.pdf 18638B, quick.txt 235B, quick.xml 143B)  defects: 1
./testRFC822_multipart_attachments.eml: Eml
  #0  -  from: Bugs Bunny <[email protected]>  subject: EML 1  attachments: 2 (Test TxtA.txt 33B, Test TxtB.txt 33B)  defects: 0
inspected 4 files/stores, 6 items, 9 attachments, 1 defects (0 ambiguities), 0 not readable

Defects

--defects lists each repair under its message, with the byte offset where it was found:

Terminal
onemail inspect --defects quick-winmail.dat
Text
quick-winmail.dat: Tnef
  #0  -  from: -  subject: -  attachments: 5 (quick.doc, quick.html, quick.pdf, quick.txt, quick.xml)  defects: 1
      mapi:LowerLayerDefect @40
inspected 1 files/stores, 1 items, 5 attachments, 1 defects (0 ambiguities), 0 not readable

JSON

--json writes one JSON object per line: one for each file or store, then one for each message.

Terminal
onemail inspect --json attachment_test_msg.msg
Text
{"type":"container","path":"attachment_test_msg.msg","format":"Msg"}
{"type":"item","index":0,"kind":"Message","provenance":{"format":"Msg","location":"attachment_test_msg.msg","folder":null,"offset":0,"length":52224},"subject":"test pi\u00E8ce jointe 1","sender":[],"from":[{"name":"Nicolas1 23456","addr":"[email protected]"}],"to":[{"name":"\[email protected]\u0027","addr":"[email protected]"}],"cc":[],"bcc":[],"replyTo":[],"date":{"utc":"2009-04-22T14:36:33Z","offsetMinutes":null,"source":"ClientSubmit"},"messageId":null,"inReplyTo":[],"references":[],"conversationTopic":"test pi\u00E8ce jointe 1","attachments":[{"name":"test-unicode.doc","type":"application/octet-stream","contentId":null,"inline":false,"embedded":false},{"name":"pj1.txt","type":"application/octet-stream","contentId":null,"inline":false,"embedded":false}],"defects":[]}

Limits

The tool’s options: Mail.Open and the read view.