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

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.

canWrite()

public final boolean canWrite()

Gets a value indicating whether the current pst supports writing.

Returns: boolean

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.

close()

public void close()

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.

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.

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.

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.

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.

dispose()

public final void dispose()

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

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.

equals(Object arg0)

public boolean equals(Object arg0)

Parameters:

Parameter Type Description
arg0 java.lang.Object

Returns: boolean

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.

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(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(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.

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.

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.

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.

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(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.

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.

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(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(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.

getClass()

public final native Class<?> getClass()

Returns: java.lang.Class

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.

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.

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

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.

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.

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.

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

hashCode()

public native int hashCode()

Returns: int

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

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

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(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.

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.

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.

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.

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.

notify()

public final native void notify()

notifyAll()

public final native void notifyAll()

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.

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.

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.

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.

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.

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.

toString()

public String toString()

Returns: java.lang.String

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

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.

wait()

public final void wait()

wait(long arg0)

public final native void wait(long arg0)

Parameters:

Parameter Type Description
arg0 long

wait(long arg0, int arg1)

public final void wait(long arg0, int arg1)

Parameters:

Parameter Type Description
arg0 long
arg1 int