com.groupdocs.parser

Interfaces

Classes

Exceptions

com.groupdocs.parser

Class PersonalStorageContainer

  • All Implemented Interfaces:
    IContainer, AutoCloseable


    public final class PersonalStorageContainer
    extends Container

    Provides a container for Outlook's Personal Storage.

    Enumerate all messages in the file:

     // Create a container for Outlook's Personal Storage
     IContainer container = new PersonalStorageContainer(stream);
     // Iterate items
     for (int i = 0; i < container.getEntities().size(); i++) {
         System.out.println("Name: " + container.getEntities().get(i)
             .getName()); // the ID of the entity
         System.out.println("Path: " + container.getEntities().get(i)
             .getPath().toString()); // path in the container
         System.out.println("Media type: " + container.getEntities().get(i)
             .getMediaType()); // media type (for example: APPLICATION/VND.MS-OUTLOOK)
         System.out.println("Subject: " + container.getEntities().get(i)
             .get_Item(MetadataNames.SUBJECT)); // email's subject
         System.out.println("" + container.getEntities().get(i)
             .get_Item(MetadataNames.EMAIL_FROM)); // email's sender (field 'from')
         System.out.println("" + container.getEntities().get(i)
             .get_Item(MetadataNames.EMAIL_TO)); // email's receiver (field 'to')
     }  
      

    Read the concrete message:

     // Create a container for Outlook's Personal Storage
     IContainer container = new PersonalStorageContainer(stream);
     // Create an extractor for the email
     EmailTextExtractor extractor = new EmailTextExtractor(container.getEntities().get(messageIndex).openStream());
     // Extract a text from the email
     System.out.println(extractor == null ? "document isn't supported" : extractor.extractAll());
      
    • Constructor Detail

      • PersonalStorageContainer

        public PersonalStorageContainer(String fileName)

        Initializes a new instance of the PersonalStorageContainer class.

        Parameters:
        fileName - The path to the file.
      • PersonalStorageContainer

        public PersonalStorageContainer(InputStream stream)

        Initializes a new instance of the PersonalStorageContainer class.

        Parameters:
        stream - The stream of the document.
    • Method Detail

      • dispose

        protected void dispose(boolean disposing)

        Releases the unmanaged resources used by the container.

        Overrides:
        dispose in class Container
        Parameters:
        disposing - A boolean true if invoked from Dispose; otherwise, false.
      • openStream

        protected InputStream openStream(Container.Entity entity)

        Returns the stream with the content of the entity.

        Specified by:
        openStream in class Container
        Parameters:
        entity - The entity.
        Returns:
        An instance of the java.io.InputStream with the content of the entity.
      • loadEntities

        protected List<Container.Entity> loadEntities()

        Returns a collection of the container's entities.

        Specified by:
        loadEntities in class Container
        Returns:
        A collection of the container's entities.