Extract emails from Outlook Storage

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Parser MCP server lets your agent work with files on your machine; they are never uploaded. It runs in Docker: replace /path/to/documents with the folder it may use.

claude mcp add groupdocs-parser -- docker run --rm -i -v /path/to/documents:/data ghcr.io/groupdocs-parser/parser-net-mcp:latest
Folders, licensing and more →

To extract emails from Outlook Storage getContainer method is used. This method returns the collection of ContainerItem objects.

Outlook Storage item can contain the following metadata:

NameDescription
dateThe time and date at which the Outlook Storage item was last modified.
email-senderThe value of “sender” field.
email-toThe value of “to” field.
subjectThe value of “subject” field.

Outlook Storage container consists of email documents (msg files).

Here are the steps to extract an email text from outlook storage:

  • Instantiate Parser object for the initial document;
  • Call getContainer method and obtain collection of ContainerItem objects;
  • Check if collection isn’t null (container extraction is supported for the document);
  • Iterate through the collection and obtain Parser object to extract a text.

The following example shows how to extract a text from emails in outlook storage:

// Create an instance of Parser class
try (Parser parser = new Parser(Constants.SampleOutlook)) {
    // Extract attachments from the container
    Iterable<ContainerItem> attachments = parser.getContainer();
    // Check if container extraction is supported
    if (attachments == null) {
        System.out.println("Container extraction isn't supported");
    }
    // Iterate over zip entities
    for (ContainerItem item : attachments) {
        // Print the file path
        System.out.println(item.getFilePath());
        // Print metadata
        for (MetadataItem metadata : item.getMetadata()) {
            System.out.println(String.format("%s: %s", metadata.getName(), metadata.getValue()));
        }
        try {
            // Create Parser object for the zip entity content
            try (Parser attachmentParser = item.openParser()) {
                // Extract an zip entity text
                try (TextReader reader = attachmentParser.getText()) {
                    System.out.println(reader == null ? "No text" : reader.readToEnd());
                }
            }
        } catch (UnsupportedDocumentFormatException ex) {
            System.out.println("Isn't supported.");
        }
    }
}

More resources

GitHub examples

You may easily run the code above and see the feature in action in our GitHub examples:

Free online document parser App

Along with full featured .NET library we provide simple, but powerful free Apps.

You are welcome to parse documents and extract data from PDF, DOC, DOCX, PPT, PPTX, XLS, XLSX, Emails and more with our free online Free Online Document Parser App.