PersonalStorage

Inheritance: java.lang.Object

All Implemented Interfaces: com.aspose.ms.System.IDisposable, java.io.Closeable

public class PersonalStorage implements System.IDisposable, Closeable

Represents Personal Storage Table (.pst) file.

Constructors

Constructor Description
PersonalStorage(TraversalExceptionsCallback callback) Initializes a new instance of the PersonalStorage class.

Fields

Field Description
ItemMoved Occurs when an item is moved to the another folder.
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.

Methods

Method Description
getRootFolder() Gets the root folder of PST.
getStore() Gets the PST message store.
getFormat() Gets the file format.
canWrite() Gets a value indicating whether the current pst supports writing.
isUnicode() Gets a value indicating whether the PST file format is Unicode.
fromFile(String fileName) Load PST from file.
fromFile(String fileName, boolean writable) Load PST from file.
fromFile(String fileName, PersonalStorageLoadOptions loadOptions) Load PST from file.
fromStream(InputStream stream, boolean writable) Load PST from stream.
fromStream(System.IO.Stream stream, boolean writable) Load PST from stream.
load(String fileName) Load PST from file.
load(InputStream stream) Load PST from stream.
load(System.IO.Stream stream) Load PST from stream.
fromStream(InputStream stream, PersonalStorageLoadOptions loadOptions) Load PST from stream.
fromStream(System.IO.Stream stream, PersonalStorageLoadOptions loadOptions) Load PST from stream.
fromStream(InputStream stream) Load PST from stream.
fromStream(System.IO.Stream stream) Load PST from stream.
create(String fileName, int version) Creates the new PST file with the specified file name.
create(System.IO.Stream stream, int version) Creates the PST in a stream.
create(System.IO.Stream stream, int version, boolean leaveStreamOpen) Creates the PST in a stream.
create(OutputStream stream, int version) Creates the PST in a stream.
create(OutputStream stream, int version, boolean leaveStreamOpen) Creates the PST in a stream.
create(OutputStream stream, int blockSize, int version) Creates the PST in a stream.
saveAs(String fileName, int format) Saves the current object to a specified file format in a different file.
saveAs(OutputStream stream, int format) Saves the current object to a specified file format in a stream.
convertTo(int format) Converts the current object to the specified format.
extractProperty(byte[] entryId, long tag) Gets the specified property of item, without extract the item fully.
extractMessage(MessageInfo messageInfo) Get the message from PST.
extractMessage(byte[] entryId) Get the message from PST.
extractMessage(String entryId) Get the message from PST.
saveMessageToStream(String entryId, OutputStream stream) Saves the message, with specified entryID, to a stream.
enumerateMessages(String entryId) Exposes the enumerator, which supports an iteration of messages in folder.
enumerateMessages(String entryId, int startIndex, int count) Exposes the enumerator, which supports an iteration of messages in folder.
tryToSaveMessage(String entryId, OutputStream stream) Saves the message, with specified entryID, to a stream.
extractAttachments(MessageInfo messageInfo) Extracts the attachments.
extractAttachments(String entryId) Extracts the attachments.
getFolderById(byte[] entryId) Gets the personal folder from PST.
tryToGetFolderById(String entryIdString, FolderInfo[] folder) Gets the folder associated with the specified entry ID.
getFolderById(String entryIdString) Gets the personal folder from PST.
findSubfolders(String parentEntryId) Finds the identifiers of subfolders for for the current folder.
findMessages(String parentEntryId) Finds the identifiers of messages for for the current folder.
getParentFolder(String entryIdString) Gets the parent folder of message.
getParentFolder(byte[] entryId) Gets the parent folder of message.
getPredefinedFolder(int defaultFolder) Gets the standard interpersonal message (IPM) folder from PST.
createPredefinedFolder(String name, int defaultFolder, boolean createHierarchy) Creates the standard interpersonal message (IPM) folder.
saveMessageToFile(String entryId, String fileName) saveMessageToFile.
createPredefinedFolder(String name, int defaultFolder) Creates the standard interpersonal message (IPM) folder.
moveItem(MessageInfo message, FolderInfo newFolder) Moves a specified message to a new folder within the current pst.
moveItem(FolderInfo folder, FolderInfo newFolder) Moves a specified folder to a new parent folder within the current pst.
mergeWith(String[] sourceFileNames) Merges the pst storage with one or more other pst files.
mergeWith(InputStream[] sourceStreams) Merges the pst storage with one or more other pst streams.
splitInto(long chunkSize, String path) Splits the pst storage into less sized parts.
splitInto(System.Collections.Generic.IGenericList criteria, String path) Splits the pst storage based on criteria.
changeMessage(String entryId, MapiPropertyCollection updatedProperties) Changes the message properties.
dispose() Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
close()

PersonalStorage(TraversalExceptionsCallback callback)

public PersonalStorage(TraversalExceptionsCallback callback)

Initializes a new instance of the PersonalStorage class. Allows setting a callback method for handling exceptions that occur during PST traversal.

Parameters:

Parameter Type Description
callback TraversalExceptionsCallback The exception callback.

ItemMoved

public final Event<ItemMovedEventHandler> ItemMoved

Occurs when an item is moved to the another folder.

StorageProcessed

public final 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.

getRootFolder()

public final FolderInfo getRootFolder()

Gets the root folder of PST.

Value: FolderInfo that represents a root folder.

Returns: FolderInfo

getStore()

public final MessageStore getStore()

Gets the PST message store.

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

Returns: MessageStore

getFormat()

public final int getFormat()

Gets the file format.

Value: FileFormat that specifies file format.


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

Returns: int

canWrite()

public final boolean canWrite()

Gets a value indicating whether the current pst supports writing.

Returns: boolean

isUnicode()

public final 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.

Returns: boolean

fromFile(String fileName)

public static PersonalStorage fromFile(String fileName)

Load PST from file.

Parameters:

Parameter Type Description
fileName java.lang.String Name of .pst file.

By default, the pst will support writing. |

Returns: PersonalStorage - A PersonalStorage object that represents the current PST.

fromFile(String fileName, boolean writable)

public static PersonalStorage fromFile(String fileName, boolean writable)

Load PST from file.

Parameters:

Parameter Type Description
fileName java.lang.String Name of .pst file.
writable boolean if set to ``` true ``` then the the pst file will support writing, otherwise it will be opened in read-only mode.

Returns: PersonalStorage - A PersonalStorage object that represents the current PST.

fromFile(String fileName, PersonalStorageLoadOptions loadOptions)

public static PersonalStorage fromFile(String fileName, PersonalStorageLoadOptions loadOptions)

Load PST from file.

Parameters:

Parameter Type Description
fileName java.lang.String Name of .pst file.
loadOptions PersonalStorageLoadOptions The load options.

Returns: PersonalStorage - A PersonalStorage object that represents the current PST.

fromStream(InputStream stream, boolean writable)

public static PersonalStorage fromStream(InputStream stream, boolean writable)

Load PST from stream.

Parameters:

Parameter Type Description
stream java.io.InputStream The System.IO.Stream.
writable boolean if set to ``` true ``` then the the pst will support writing, otherwise it will be opened in read-only mode.

Returns: PersonalStorage - A PersonalStorage object that represents the current PST.

fromStream(System.IO.Stream stream, boolean writable)

public static PersonalStorage fromStream(System.IO.Stream stream, boolean writable)

Load PST from stream.

Parameters:

Parameter Type Description
stream com.aspose.ms.System.IO.Stream The System.IO.Stream.
writable boolean if set to ``` true ``` then the the pst will support writing, otherwise it will be opened in read-only mode.

Returns: PersonalStorage - A PersonalStorage object that represents the current PST.

load(String fileName)

public final boolean load(String fileName)

Load PST from file. This method is used when a PersonalStorage object is created using the constructor.

Parameters:

Parameter Type Description
fileName java.lang.String The name of .pst file.

Returns: boolean - ’true’ if the file has been loaded successfully and further traversal is possible; otherwise, false.

load(InputStream stream)

public final boolean load(InputStream stream)

Load PST from stream. This method is used when a PersonalStorage object is created using the constructor.

Parameters:

Parameter Type Description
stream java.io.InputStream The System.IO.Stream.

Returns: boolean - ’true’ if the file has been loaded successfully and further traversal is possible; otherwise, false.

load(System.IO.Stream stream)

public final boolean load(System.IO.Stream stream)

Load PST from stream. This method is used when a PersonalStorage object is created using the constructor.

Parameters:

Parameter Type Description
stream com.aspose.ms.System.IO.Stream The System.IO.Stream.

Returns: boolean

fromStream(InputStream stream, PersonalStorageLoadOptions loadOptions)

public static PersonalStorage fromStream(InputStream stream, PersonalStorageLoadOptions loadOptions)

Load PST from stream.

Parameters:

Parameter Type Description
stream java.io.InputStream The System.IO.Stream.
loadOptions PersonalStorageLoadOptions The load options.

Returns: PersonalStorage - A PersonalStorage object that represents the current PST.

fromStream(System.IO.Stream stream, PersonalStorageLoadOptions loadOptions)

public static PersonalStorage fromStream(System.IO.Stream stream, PersonalStorageLoadOptions loadOptions)

Load PST from stream.

Parameters:

Parameter Type Description
stream com.aspose.ms.System.IO.Stream The System.IO.Stream.
loadOptions PersonalStorageLoadOptions The load options.

Returns: PersonalStorage - A PersonalStorage object that represents the current PST.

fromStream(InputStream stream)

public static PersonalStorage fromStream(InputStream stream)

Load PST from stream.

Parameters:

Parameter Type Description
stream java.io.InputStream The System.IO.Stream.

By default, the pst will support writing. |

Returns: PersonalStorage - A PersonalStorage object that represents the current PST.

fromStream(System.IO.Stream stream)

public static PersonalStorage fromStream(System.IO.Stream stream)

Load PST from stream.

Parameters:

Parameter Type Description
stream com.aspose.ms.System.IO.Stream The System.IO.Stream.

By default, the pst will support writing. |

Returns: PersonalStorage - A PersonalStorage object that represents the current PST.

create(String fileName, int version)

public static PersonalStorage create(String fileName, int version)

Creates the new PST file with the specified file name.

Parameters:

Parameter Type Description
fileName java.lang.String The full name of the file.
version int The PST file version.

Note, only Unicode file version creation is supported now. |

Returns: PersonalStorage - A PersonalStorage object that represents the new PST.

create(System.IO.Stream stream, int version)

public static PersonalStorage create(System.IO.Stream stream, int version)

Creates the PST in a stream.

Parameters:

Parameter Type Description
stream com.aspose.ms.System.IO.Stream The stream in which PST is created.
version int The PST file version.

Note, only Unicode file version creation is supported now. |

Returns: PersonalStorage - A PersonalStorage object that represents the new PST.

create(System.IO.Stream stream, int version, boolean leaveStreamOpen)

public static PersonalStorage create(System.IO.Stream stream, int version, boolean leaveStreamOpen)

Creates the PST in a stream.

Parameters:

Parameter Type Description
stream com.aspose.ms.System.IO.Stream The stream in which PST is created.
version int The PST file version.
leaveStreamOpen boolean Leave stream open when PersonalStorage is disposed.

Note, only Unicode file version creation is supported now. |

Returns: PersonalStorage - A PersonalStorage object that represents the new PST.

create(OutputStream stream, int version)

public static PersonalStorage create(OutputStream stream, int version)

Creates the PST in a stream.

Parameters:

Parameter Type Description
stream java.io.OutputStream The stream in which PST is created.
version int The PST file version.

Note, only Unicode file version creation is supported now. |

Returns: PersonalStorage - A PersonalStorage object that represents the new PST.

create(OutputStream stream, int version, boolean leaveStreamOpen)

public static PersonalStorage create(OutputStream stream, int version, boolean leaveStreamOpen)

Creates the PST in a stream.

Parameters:

Parameter Type Description
stream java.io.OutputStream The stream in which PST is created.
version int The PST file version.
leaveStreamOpen boolean Leave stream open when PersonalStorage is disposed.

Note, only Unicode file version creation is supported now. |

Returns: PersonalStorage - A PersonalStorage object that represents the new PST.

create(OutputStream stream, int blockSize, int version)

public static PersonalStorage create(OutputStream stream, int blockSize, int version)

Creates the PST in a stream.

Parameters:

Parameter Type Description
stream java.io.OutputStream The stream in which PST is created.
blockSize int The optimal block size to expand cache buffer(in bytes).
version int The PST file version.

Note, only Unicode file version creation is supported now. |

Returns: PersonalStorage - A PersonalStorage object that represents the new PST.

saveAs(String fileName, int format)

public final void saveAs(String fileName, int format)

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

Parameters:

Parameter Type Description
fileName java.lang.String The name of the file to be saved.
format int The FileFormat is to be used when saving a file.

saveAs(OutputStream stream, int format)

public final void saveAs(OutputStream stream, int format)

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

Parameters:

Parameter Type Description
stream java.io.OutputStream The stream to be saved.
format int The FileFormat is to be used.

convertTo(int format)

public final void convertTo(int format)

Converts the current object to the specified format.

Parameters:

Parameter Type Description
format int The FileFormat to convert the current object to.

extractProperty(byte[] entryId, long tag)

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

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

Parameters:

Parameter Type Description
entryId byte[] The entry id of item.
tag long The property tag.

If a property is not found, null is returned. |

Returns: MapiProperty - The MapiProperty.

extractMessage(MessageInfo messageInfo)

public final MapiMessage extractMessage(MessageInfo messageInfo)

Get the message from PST.

Parameters:

Parameter Type Description
messageInfo MessageInfo A MessageInfo object that represents information about message.

Returns: MapiMessage - A MapiMessage object.

extractMessage(byte[] entryId)

public final MapiMessage extractMessage(byte[] entryId)

Get the message from PST.

Parameters:

Parameter Type Description
entryId byte[] EntryId of message.

Returns: MapiMessage - A MapiMessage object.

extractMessage(String entryId)

public final MapiMessage extractMessage(String entryId)

Get the message from PST.

Parameters:

Parameter Type Description
entryId java.lang.String String representation of EntryId.

Returns: MapiMessage - A MapiMessage object.

saveMessageToStream(String entryId, OutputStream stream)

public final void saveMessageToStream(String entryId, OutputStream stream)

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

Parameters:

Parameter Type Description
entryId java.lang.String The entry id.
stream java.io.OutputStream The stream for writing.

enumerateMessages(String entryId)

public final System.Collections.Generic.IGenericEnumerable<MessageInfo> enumerateMessages(String entryId)

Exposes the enumerator, which supports an iteration of messages in folder.

Parameters:

Parameter Type Description
entryId java.lang.String The string that represents a parent folder entry ID.

Returns: com.aspose.ms.System.Collections.Generic.IGenericEnumerable<com.aspose.email.MessageInfo> - ``` System.Collections.Generic.IEnumerableltTgt ```, that represents an enumerator that iterates through a messages in folder.

enumerateMessages(String entryId, int startIndex, int count)

public final System.Collections.Generic.IGenericEnumerable<MessageInfo> enumerateMessages(String entryId, int startIndex, int count)

Exposes the enumerator, which supports an iteration of messages in folder.

Parameters:

Parameter Type Description
entryId java.lang.String The string that represents a parent folder entry ID.
startIndex int The start message index.
count int The number of messages that will be retrieved.

Returns: com.aspose.ms.System.Collections.Generic.IGenericEnumerable<com.aspose.email.MessageInfo> - ``` System.Collections.Generic.IEnumerableltTgt ```, that represents an enumerator that iterates through a messages in folder.

tryToSaveMessage(String entryId, OutputStream stream)

public final SaveResult tryToSaveMessage(String entryId, OutputStream stream)

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

Parameters:

Parameter Type Description
entryId java.lang.String The entry id.
stream java.io.OutputStream The stream for writing.

Returns: SaveResult - The SaveResult that represents the result of item saving.

extractAttachments(MessageInfo messageInfo)

public final MapiAttachmentCollection extractAttachments(MessageInfo messageInfo)

Extracts the attachments.

Parameters:

Parameter Type Description
messageInfo MessageInfo The message information.

Returns: MapiAttachmentCollection - The MapiAttachmentCollection that represents the collection of attachments.

extractAttachments(String entryId)

public final MapiAttachmentCollection extractAttachments(String entryId)

Extracts the attachments.

Parameters:

Parameter Type Description
entryId java.lang.String The message entryId.

Returns: MapiAttachmentCollection - The MapiAttachmentCollection that represents the collection of attachments.

getFolderById(byte[] entryId)

public final FolderInfo getFolderById(byte[] entryId)

Gets the personal folder from PST.

Parameters:

Parameter Type Description
entryId byte[] The Entry id.

Returns: FolderInfo - A FolderInfo object.

tryToGetFolderById(String entryIdString, FolderInfo[] folder)

public final boolean tryToGetFolderById(String entryIdString, FolderInfo[] folder)

Gets the folder associated with the specified entry ID.

Parameters:

Parameter Type Description
entryIdString java.lang.String The string that represented the entry ID.
folder com.aspose.email.FolderInfo[] When this method returns true, contains the FolderInfo object associated with the specified ID.

Returns: boolean - true if the folder is successfully found; otherwise, false.

getFolderById(String entryIdString)

public final FolderInfo getFolderById(String entryIdString)

Gets the personal folder from PST.

Parameters:

Parameter Type Description
entryIdString java.lang.String String representation of entry ID.

Returns: FolderInfo - A FolderInfo object.

findSubfolders(String parentEntryId)

public final System.Collections.Generic.IGenericList<String> findSubfolders(String parentEntryId)

Finds the identifiers of subfolders for for the current folder. It might be useful in case of reading corrupted pst when the GetSubfolders and EnumerateFolders methods could throw an exception.

Parameters:

Parameter Type Description
parentEntryId java.lang.String Entry id of the parent folder.

Returns: com.aspose.ms.System.Collections.Generic.IGenericList<java.lang.String> - Collection of entry Ids.

findMessages(String parentEntryId)

public final System.Collections.Generic.IGenericList<String> findMessages(String parentEntryId)

Finds the identifiers of messages for for the current folder. It might be useful in case of reading corrupted pst when the GetContents and EnumerateMessages methods could throw an exception.

Parameters:

Parameter Type Description
parentEntryId java.lang.String Entry id of the parent folder.

Returns: com.aspose.ms.System.Collections.Generic.IGenericList<java.lang.String> - Collection of entry Ids.

getParentFolder(String entryIdString)

public final FolderInfo getParentFolder(String entryIdString)

Gets the parent folder of message.

Parameters:

Parameter Type Description
entryIdString java.lang.String String representation of Entry Id of message or folder.

Returns: FolderInfo - The parent folderFolderInfo of message.

getParentFolder(byte[] entryId)

public final FolderInfo getParentFolder(byte[] entryId)

Gets the parent folder of message.

Parameters:

Parameter Type Description
entryId byte[] Entry Id of message or folder.

Returns: FolderInfo - The parent folderFolderInfo of message.

getPredefinedFolder(int defaultFolder)

public final 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:

Parameter Type Description
defaultFolder int The value of StandardIpmFolder enumeration.

Returns: FolderInfo - A FolderInfo object that represents a standard IPM folder.

createPredefinedFolder(String name, int defaultFolder, boolean createHierarchy)

public final FolderInfo createPredefinedFolder(String name, int defaultFolder, boolean createHierarchy)

Creates the standard interpersonal message (IPM) folder.

Parameters:

Parameter Type Description
name java.lang.String The name of folder.
defaultFolder int The value of StandardIpmFolder enumeration.
createHierarchy boolean if set to ``` true ```, it is possible to create a folder hierarchy using string notation. Backslash (’\’) is used as path separator.

Returns: FolderInfo - A FolderInfo object that represents a standard IPM folder.

saveMessageToFile(String entryId, String fileName)

public void saveMessageToFile(String entryId, String fileName)

saveMessageToFile.

Parameters:

Parameter Type Description
entryId java.lang.String a java.lang.String object.
fileName java.lang.String a java.lang.String object.

createPredefinedFolder(String name, int defaultFolder)

public final FolderInfo createPredefinedFolder(String name, int defaultFolder)

Creates the standard interpersonal message (IPM) folder.

Parameters:

Parameter Type Description
name java.lang.String The name of folder.
defaultFolder int The value of StandardIpmFolder enumeration.

Returns: FolderInfo - A FolderInfo object that represents a standard IPM folder.

moveItem(MessageInfo message, FolderInfo newFolder)

public final void moveItem(MessageInfo message, FolderInfo newFolder)

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

Parameters:

Parameter Type Description
message MessageInfo The message to move.
newFolder FolderInfo The new folder for the message.

moveItem(FolderInfo folder, FolderInfo newFolder)

public final void moveItem(FolderInfo folder, FolderInfo newFolder)

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

Parameters:

Parameter Type Description
folder FolderInfo The folder to move.
newFolder FolderInfo The new parent folder.

mergeWith(String[] sourceFileNames)

public final void mergeWith(String[] sourceFileNames)

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

Parameters:

Parameter Type Description
sourceFileNames java.lang.String[] The source file names.

mergeWith(InputStream[] sourceStreams)

public final void mergeWith(InputStream[] sourceStreams)

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

Parameters:

Parameter Type Description
sourceStreams java.io.InputStream[] The source streams.

splitInto(long chunkSize, String path)

public final void splitInto(long chunkSize, String path)

Splits the pst storage into less sized parts.

Parameters:

Parameter Type Description
chunkSize long The approximate size of a chunk in bytes.
path java.lang.String The folder path where chunks will be created.

splitInto(System.Collections.Generic.IGenericList criteria, String path)

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

Splits the pst storage based on criteria.

Parameters:

Parameter Type Description
criteria com.aspose.ms.System.Collections.Generic.IGenericList<com.aspose.email.MailQuery> The collection of MailQuery that represents criteria of pst splitting.
path java.lang.String The folder path where chunks will be created.

changeMessage(String entryId, MapiPropertyCollection updatedProperties)

public final void changeMessage(String entryId, MapiPropertyCollection updatedProperties)

Changes the message properties.

Parameters:

Parameter Type Description
entryId java.lang.String The entry identifier of message.
updatedProperties MapiPropertyCollection The updated properties.

dispose()

public final void dispose()

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

close()

public void close()