com.aspose.email

Interfaces

Classes

Enums

Exceptions

com.aspose.email

Class PersonalStorage

  • All Implemented Interfaces:
    com.aspose.ms.System.IDisposable


    public class PersonalStorage
    extends Object
    implements com.aspose.ms.System.IDisposable

    Represents Personal Storage Table (.pst) file.

    • Field Detail

      • ItemMoved

        public final com.aspose.ms.lang.Event<ItemMovedEventHandler> ItemMoved

        Occurs when an item is moved to the another folder.

      • StorageProcessed

        public final com.aspose.ms.lang.Event<StorageProcessedEventHandler> StorageProcessed

        Occurs in splitting and merging operations when a new chunk of pst is created or the next file is processed and is to be merged.

    • Method Detail

      • getRootFolder

        public FolderInfo getRootFolder()

        Gets the root folder of PST.

        Value: FolderInfo that represents a root folder.
      • getStore

        public MessageStore getStore()

        Gets the PST message store.

        Value: The MessageStore which is the rough equivalent of the top of a Mailbox.
      • getFormat

        public int getFormat()

        Gets the file format.

        Value: FileFormat that specifies file format.


        The .pst and .ost file formats are supported now.

      • canWrite

        public boolean canWrite()

        Gets a value indicating whether the current pst supports writing.

      • isUnicode

        public boolean isUnicode()

        Gets a value indicating whether the PST file format is Unicode. There are two versions of the PST file format: Unicode and ANSI.

      • fromFile

        public static PersonalStorage fromFile(String fileName)

        Load PST from file.

        Parameters:
        fileName - Name of .pst file.


        By default, the pst will support writing.

        Returns:
        A PersonalStorage object that represents the current PST.
      • fromFile

        public static PersonalStorage fromFile(String fileName,
                               boolean writable)

        Load PST from file.

        Parameters:
        fileName - Name of .pst file.
        writable - if set to true then the the pst file will support writing, otherwise it will be opened in read-only mode.
        Returns:
        A PersonalStorage object that represents the current PST.
      • fromStream

        public static PersonalStorage fromStream(InputStream stream,
                                 boolean writable)

        Load PST from stream.

        Parameters:
        stream - The System.IO.Stream.
        writable - if set to true then the the pst will support writing, otherwise it will be opened in read-only mode.
        Returns:
        A PersonalStorage object that represents the current PST.
      • fromStream

        public static PersonalStorage fromStream(InputStream stream)

        Load PST from stream.

        Parameters:
        stream - The System.IO.Stream.


        By default, the pst will support writing.

        Returns:
        A PersonalStorage object that represents the current PST.
      • create

        public static PersonalStorage create(String fileName,
                             int version)

        Creates the new PST file with the specified file name.

        Parameters:
        fileName - The full name of the file.
        version - The PST file version.


        Note, only Unicode file version creation is supported now.

        Returns:
        A PersonalStorage object that represents the new PST.
        Throws:
        com.aspose.ms.System.NotImplementedException - throws if ANSI file version is created
        com.aspose.ms.System.ArgumentNullException - throws if file name is null or empty
      • create

        public static PersonalStorage create(OutputStream stream,
                             int version)

        Creates the PST in a stream.

        Parameters:
        stream - The stream in which PST is created.
        version - The PST file version.


        Note, only Unicode file version creation is supported now.

        Returns:
        A PersonalStorage object that represents the new PST.
        Throws:
        com.aspose.ms.System.NotImplementedException - throws if ANSI file version is created
        com.aspose.ms.System.ArgumentNullException - throws if stream is null
      • saveAs

        public void saveAs(String fileName,
                  int format)

        Saves the current object to a specified file format in a different file.

        Parameters:
        fileName - The name of the file to be saved.
        format - The FileFormat is to be used when saving a file.
      • convertTo

        public void convertTo(int format)

        Converts the current object to the specified format.

        Parameters:
        format - The FileFormat to convert the current object to.
      • extractProperty

        public MapiProperty extractProperty(byte[] entryId,
                                   long tag)

        Gets the specified property of item, without extract the item fully.

        Parameters:
        entryId - The entry id of item.
        tag - The property tag.


        If a property is not found, null is returned.

        Returns:
        The MapiProperty.
      • extractMessage

        public MapiMessage extractMessage(MessageInfo messageInfo)

        Get the message from PST.

        Parameters:
        messageInfo - A MessageInfo object that represents information about message.
        Returns:
        A MapiMessage object.
      • extractMessage

        public MapiMessage extractMessage(byte[] entryId)

        Get the message from PST.

        Parameters:
        entryId - EntryId of message.
        Returns:
        A MapiMessage object.
      • extractMessage

        public MapiMessage extractMessage(String entryId)

        Get the message from PST.

        Parameters:
        entryId - String representation of EntryId.
        Returns:
        A MapiMessage object.
      • saveMessageToStream

        public void saveMessageToStream(String entryId,
                               OutputStream stream)

        Saves the message, with specified entryID, to a stream.

        Parameters:
        entryId - The entry id.
        stream - The stream for writing.
      • extractAttachments

        public MapiAttachmentCollection extractAttachments(MessageInfo messageInfo)

        Extracts the attachments.

        Parameters:
        messageInfo - The message information.
        Returns:
        The MapiAttachmentCollection that represents the collection of attachments.
      • extractAttachments

        public MapiAttachmentCollection extractAttachments(String entryId)

        Extracts the attachments.

        Parameters:
        entryId - The message entryId.
        Returns:
        The MapiAttachmentCollection that represents the collection of attachments.
      • getFolderById

        public FolderInfo getFolderById(byte[] entryId)

        Gets the personal folder from PST.

        Parameters:
        entryId - The Entry id.
        Returns:
        A FolderInfo object.
      • getFolderById

        public FolderInfo getFolderById(String entryIdString)

        Gets the personal folder from PST.

        Parameters:
        entryIdString - String representation of entry ID.
        Returns:
        A FolderInfo object.
      • getParentFolder

        public FolderInfo getParentFolder(String entryIdString)

        Gets the parent folder of message.

        Parameters:
        entryIdString - String representation of Entry Id of message or folder.
        Returns:
        The parent folderFolderInfo of message.
      • getParentFolder

        public FolderInfo getParentFolder(byte[] entryId)

        Gets the parent folder of message.

        Parameters:
        entryId - Entry Id of message or folder.
        Returns:
        The parent folderFolderInfo of message.
      • getPredefinedFolder

        public FolderInfo getPredefinedFolder(int defaultFolder)

        Gets the standard interpersonal message (IPM) folder from PST. Outlook can create a number of default folders, such as Outbox, Deleted Items, Sent Items etc.

        Parameters:
        defaultFolder - The value of StandardIpmFolder enumeration.
        Returns:
        A FolderInfo object that represents a standard IPM folder.
      • saveMessageToFile

        public void saveMessageToFile(String entryId,
                             String fileName)

        saveMessageToFile.

        Parameters:
        entryId - a String object.
        fileName - a String object.
      • createPredefinedFolder

        public FolderInfo createPredefinedFolder(String name,
                                        int defaultFolder)

        Creates the standard interpersonal message (IPM) folder.

        Parameters:
        name - The name of folder.
        defaultFolder - The value of StandardIpmFolder enumeration.
        Returns:
        A FolderInfo object that represents a standard IPM folder.
      • moveItem

        public void moveItem(MessageInfo message,
                    FolderInfo newFolder)

        Moves a specified message to a new folder within the current pst.

        Parameters:
        message - The message to move.
        newFolder - The new folder for the message.
      • moveItem

        public void moveItem(FolderInfo folder,
                    FolderInfo newFolder)

        Moves a specified folder to a new parent folder within the current pst.

        Parameters:
        folder - The folder to move.
        newFolder - The new parent folder.
      • mergeWith

        public void mergeWith(String[] sourceFileNames)

        Merges the pst storage with one or more other pst files. Thus, the combined files are sources.

        Parameters:
        sourceFileNames - The source file names.
        Throws:
        com.aspose.ms.System.ArgumentNullException - "Throws when the filename collection is null."
        com.aspose.ms.System.ArgumentException - "Throws when the filename in collection is null or empty."
      • splitInto

        public void splitInto(long chunkSize,
                     String path)

        Splits the pst storage into less sized parts.

        Parameters:
        chunkSize - The approximate size of a chunk in bytes.
        path - The folder path where chunks will be created.
        Throws:
        com.aspose.ms.System.ArgumentException - Throws when the path parameter is null or empty.
        com.aspose.ms.System.ArgumentException - Throws when the chunk size is less then the minimum size of pst file.
      • splitInto

        public void splitInto(com.aspose.ms.System.Collections.Generic.IGenericList<MailQuery> criteria,
                     String path)

        Splits the pst storage based on criteria.

        Parameters:
        criteria - The collection of MailQuery that represents criteria of pst splitting.
        path - The folder path where chunks will be created.
        Throws:
        com.aspose.ms.System.ArgumentException - Throws when the path parameter is null or empty.
      • changeMessage

        public void changeMessage(String entryId,
                         MapiPropertyCollection updatedProperties)

        Changes the message properties.

        Parameters:
        entryId - The entry identifier of message.
        updatedProperties - The updated properties.
        Throws:
        com.aspose.ms.System.NotImplementedException - The ANSI file version editing is not implemented.
        com.aspose.ms.System.InvalidOperationException - The PST is open for reading only. or The entryId is incorrect.
        com.aspose.ms.System.ArgumentNullException - entryIdCollection;The collection of entry ids cannot be null. or updatedProperties;The collection of properties cannot be null.
      • dispose

        public void dispose()

        Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

        Specified by:
        dispose in interface com.aspose.ms.System.IDisposable
      • dispose

        protected void dispose(boolean disposing)

        Releases unmanaged and - optionally - managed resources.

        Parameters:
        disposing - true to release both managed and unmanaged resources; false to release only unmanaged resources.