Provides functionality to access and manipulate the PST (Personal Storage Table) files used by Microsoft Outlook. More...

Inherits IDisposable.

Public Member Functions

System::SharedPtr< FolderInfoget_RootFolder () const
 Gets the root folder of PST. More...
 
System::SharedPtr< MessageStoreget_Store () const
 Gets the PST message store. More...
 
FileFormat get_Format ()
 Gets the file format. More...
 
bool get_CanWrite ()
 Gets a value indicating whether the current pst supports writing. More...
 
bool get_IsUnicode ()
 Gets a value indicating whether the PST file format is Unicode. There are two versions of the PST file format: Unicode and ANSI. More...
 
 PersonalStorage (Exceptions::TraversalExceptionsCallback callback)
 Initializes a new instance of the PersonalStorage class. Allows setting a callback method for handling exceptions that occur during PST traversal. More...
 
bool Load (System::String fileName)
 Load PST from file. This method is used when a PersonalStorage object is created using the constructor. More...
 
bool Load (System::SharedPtr< System::IO::Stream > stream)
 Load PST from stream. This method is used when a PersonalStorage object is created using the constructor. More...
 
VentureLicenseState GetVentureLicenseState ()
 
void SaveAs (System::String fileName, FileFormat format)
 Saves the current object to a specified file format in a different file. More...
 
void SaveAs (System::SharedPtr< System::IO::Stream > stream, FileFormat format)
 Saves the current object to a specified file format in a stream. More...
 
void ConvertTo (FileFormat format)
 Converts the current object to the specified format. More...
 
System::SharedPtr< Mapi::MapiPropertyExtractProperty (System::ArrayPtr< uint8_t > entryId, int64_t tag)
 Gets the specified property of item, without extract the item fully. More...
 
System::SharedPtr< Mapi::MapiMessageExtractMessage (System::SharedPtr< MessageInfo > messageInfo)
 Get the message from PST. More...
 
System::SharedPtr< Mapi::MapiMessageExtractMessage (System::ArrayPtr< uint8_t > entryId)
 Get the message from PST. More...
 
System::SharedPtr< Mapi::MapiMessageExtractMessage (System::String entryId)
 Get the message from PST. More...
 
void DeleteItem (System::String entryId)
 Deletes the item (folder or message) by it's entryId More...
 
void SaveMessageToStream (System::String entryId, System::SharedPtr< System::IO::Stream > stream)
 Saves the message, with specified entryID, to a stream. More...
 
System::SharedPtr< System::Collections::Generic::IEnumerable< System::SharedPtr< MessageInfo > > > EnumerateMessages (System::String entryId)
 Exposes the enumerator, which supports an iteration of messages in folder. More...
 
System::SharedPtr< System::Collections::Generic::IEnumerable< System::SharedPtr< MessageInfo > > > EnumerateMessages (System::String entryId, int32_t startIndex, int32_t count)
 Exposes the enumerator, which supports an iteration of messages in folder. More...
 
System::SharedPtr< SaveResultTryToSaveMessage (System::String entryId, System::SharedPtr< System::IO::Stream > stream)
 Saves the message, with specified entryID, to a stream. More...
 
void AddAttachmentToMessage (System::SharedPtr< MessageInfo > messageInfo, System::String name, System::SharedPtr< System::IO::Stream > stream)
 Adds an attachment to the specified message using the provided stream as attachment content. More...
 
void AddAttachmentToMessage (System::SharedPtr< MessageInfo > messageInfo, System::String filePath)
 Adds an attachment to the specified message using the file located at the provided path. More...
 
void AddAttachmentToMessage (System::String entryId, System::String name, System::SharedPtr< System::IO::Stream > stream)
 Adds an attachment to the message identified by the specified entry ID using the provided stream. More...
 
void AddAttachmentToMessage (System::String entryId, System::String filePath)
 Adds an attachment to the message identified by the specified entry ID using the file located at the provided path. More...
 
System::SharedPtr< Mapi::MapiAttachmentCollectionExtractAttachments (System::SharedPtr< MessageInfo > messageInfo)
 Extracts the attachments. More...
 
System::SharedPtr< Mapi::MapiRecipientCollectionExtractRecipients (System::SharedPtr< MessageInfo > messageInfo)
 Extracts the recipients. More...
 
System::SharedPtr< Mapi::MapiRecipientCollectionExtractRecipients (System::String entryId)
 Extracts the recipients. More...
 
System::SharedPtr< Mapi::MapiAttachmentCollectionExtractAttachments (System::String entryId)
 Extracts the attachments. More...
 
System::SharedPtr< FolderInfoGetFolderById (System::ArrayPtr< uint8_t > entryId)
 Gets the personal folder from PST. More...
 
bool TryToGetFolderById (System::String entryIdString, System::SharedPtr< FolderInfo > &folder)
 Gets the folder associated with the specified entry ID. More...
 
System::SharedPtr< FolderInfoGetFolderById (System::String entryIdString)
 Gets the personal folder from PST. More...
 
System::SharedPtr< System::Collections::Generic::IList< System::String > > FindSubfolders (System::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. More...
 
System::SharedPtr< System::Collections::Generic::IList< System::String > > FindMessages (System::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. More...
 
System::SharedPtr< System::Collections::Generic::IList< System::SharedPtr< RestoredItemEntry > > > FindAndExtractSoftDeletedItems ()
 Finds and extracts soft-deleted messages from the PST. More...
 
System::SharedPtr< FolderInfoGetParentFolder (System::String entryIdString)
 Finds and enumerates all soft-deleted items. More...
 
System::SharedPtr< FolderInfoGetParentFolder (System::ArrayPtr< uint8_t > entryId)
 Gets the parent folder of message. More...
 
System::SharedPtr< FolderInfoGetPredefinedFolder (StandardIpmFolder 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. More...
 
System::SharedPtr< System::Collections::Generic::ListExt< System::SharedPtr< PstItemCategory > > > GetCategories ()
 Retrieves a list of PST item categories, each containing a name and associated color. More...
 
System::SharedPtr< FolderInfoCreatePredefinedFolder (System::String name, StandardIpmFolder defaultFolder, bool createHierarchy)
 Creates the standard interpersonal message (IPM) folder. More...
 
System::SharedPtr< FolderInfoCreatePredefinedFolder (System::String name, StandardIpmFolder defaultFolder)
 Creates the standard interpersonal message (IPM) folder. More...
 
void MoveItem (System::SharedPtr< MessageInfo > message, System::SharedPtr< FolderInfo > newFolder)
 Moves a specified message to a new folder within the current pst. More...
 
void MoveItem (System::SharedPtr< FolderInfo > folder, System::SharedPtr< FolderInfo > newFolder)
 Moves a specified folder to a new parent folder within the current pst. More...
 
void MergeWith (System::ArrayPtr< System::String > sourceFileNames)
 Merges the pst storage with one or more other pst files. Thus, the combined files are sources. More...
 
void MergeWith (System::ArrayPtr< System::SharedPtr< System::IO::Stream >> sourceStreams)
 Merges the pst storage with one or more other pst streams. Thus, the combined stream are sources. More...
 
void Cancel ()
 This method used to interrupt a split operation. More...
 
void SplitInto (int64_t chunkSize, System::String path)
 Splits the pst storage into less sized parts. More...
 
void SplitInto (System::SharedPtr< System::Collections::Generic::IList< System::SharedPtr< Tools::Search::MailQuery >>> criteria, System::String path)
 Splits the pst storage based on criteria. More...
 
void SplitInto (int64_t chunkSize, System::String partFileNamePrefix, System::String path)
 Splits the pst storage into less sized parts. More...
 
void SplitInto (System::SharedPtr< System::Collections::Generic::IList< System::SharedPtr< Tools::Search::MailQuery >>> criteria, System::String partFileNamePrefix, System::String path)
 Splits the pst storage based on criteria. More...
 
void ChangeMessage (System::String entryId, System::SharedPtr< Mapi::MapiPropertyCollection > updatedProperties)
 Changes the message properties. More...
 
System::SharedPtr< PersonalStorageCreateFolderMapping (System::SharedPtr< System::Collections::Generic::Dictionary< uint32_t, uint32_t >> table)
 Clones the folder structure. More...
 
System::SharedPtr< PersonalStorageCloneFolderStructure (System::String fileName, System::SharedPtr< System::Collections::Generic::Dictionary< uint32_t, uint32_t >> table)
 Clones the folder structure. More...
 
void OnStorageProcessed (System::SharedPtr< StorageProcessedEventArgs > e)
 Raises the E:ChunkCreated event. More...
 
void Dispose () override
 Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. More...
 

Static Public Member Functions

static System::SharedPtr< PersonalStorageFromFile (System::String fileName)
 Load PST from file. More...
 
static System::SharedPtr< PersonalStorageFromFile (System::String fileName, bool writable)
 Load PST from file. More...
 
static System::SharedPtr< PersonalStorageFromFile (System::String fileName, System::SharedPtr< PersonalStorageLoadOptions > loadOptions)
 Load PST from file. More...
 
static System::SharedPtr< PersonalStorageFromStream (System::SharedPtr< System::IO::Stream > stream, bool writable)
 Load PST from stream. More...
 
static System::SharedPtr< PersonalStorageFromStream (System::SharedPtr< System::IO::Stream > stream, System::SharedPtr< PersonalStorageLoadOptions > loadOptions)
 Load PST from stream. More...
 
static System::SharedPtr< PersonalStorageFromStream (System::SharedPtr< System::IO::Stream > stream)
 Load PST from stream. More...
 
static System::SharedPtr< PersonalStorageCreate (System::String fileName, FileFormatVersion version)
 Creates the new PST file with the specified file name. More...
 
static System::SharedPtr< PersonalStorageCreate (System::SharedPtr< System::IO::Stream > stream, FileFormatVersion version)
 Creates the PST in a stream. More...
 
static System::SharedPtr< PersonalStorageCreate (System::SharedPtr< System::IO::Stream > stream, FileFormatVersion version, bool leaveStreamOpen)
 Creates the PST in a stream. More...
 

Public Attributes

System::SharedPtr< PstDoer > pstDoer
 The pst reader. More...
 
System::Event< void(System::SharedPtr< System::Object >, System::SharedPtr< Aspose::Email::Storage::Pst::ItemMovedEventArgs >)> ItemMoved
 Occurs when an item is moved to the another folder. More...
 
System::Event< void(System::SharedPtr< System::Object >, System::SharedPtr< Aspose::Email::Storage::Pst::StorageProcessedEventArgs >)> 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. More...
 
System::Event< void(System::SharedPtr< System::Object >, System::SharedPtr< Aspose::Email::Storage::Pst::StorageProcessingEventArgs >)> StorageProcessing
 Occurs before the srorage is processed. The event is raised before processing the next storage in merging or splitting operations. More...
 

Protected Member Functions

virtual void Dispose (bool disposing)
 Releases unmanaged and - optionally - managed resources. More...
 
virtual ~PersonalStorage ()
 

Detailed Description

Provides functionality to access and manipulate the PST (Personal Storage Table) files used by Microsoft Outlook.

The PersonalStorage class encapsulates methods for creating, opening, and working with the contents of PST files including emails, appointments, contacts, tasks, and other personal information.

This code serves as a way to browse and extract messages from a PST file, printing metadata about each folder and message, extract and saving the actual messages as .msg files.

[C#]

// Open the PST file by creating an instance of PersonalStorage
using (var pst = PersonalStorage.FromFile("storage.pst"))
{
// Retrieve the total number of items in the PST file
var totalItemsCount = pst.Store.GetTotalItemsCount();
// Write the total items count to the console
Console.WriteLine($"Total items count: {totalItemsCount}");
// Iterate through each subfolder within the root folder of the PST
foreach (var folderInfo in pst.RootFolder.GetSubFolders())
{
// Write the display name of the folder to the console
Console.WriteLine($"Folder: {folderInfo.DisplayName}");
// Write the total number of items in the folder to the console
Console.WriteLine($"Total items: {folderInfo.ContentCount}");
// Write the count of unread items in the folder to the console
Console.WriteLine($"Total unread items: {folderInfo.ContentUnreadCount}");
// Enumerate through each message in the current folder
foreach (var messageInfo in folderInfo.EnumerateMessages())
{
// Write the subject of the message to the console
Console.WriteLine($"Subject: {messageInfo.Subject}");
// Extract the full message object from the messageInfo
var msg = pst.ExtractMessage(messageInfo);
// Save the message as a .msg file, using its subject as the filename
msg.Save($"{msg.Subject}.msg");
}
}
}

[Visual Basic]

' Open the PST file by creating an instance of PersonalStorage
Using pst As PersonalStorage = PersonalStorage.FromFile("storage.pst")
' Retrieve the total number of items in the PST file
Dim totalItemsCount As Integer = pst.Store.GetTotalItemsCount()
' Write the total items count to the console
Console.WriteLine($"Total items count: {totalItemsCount}")
' Iterate through each subfolder within the root folder of the PST
For Each folderInfo In pst.RootFolder.GetSubFolders()
' Write the display name of the folder to the console
Console.WriteLine($"Folder: {folderInfo.DisplayName}")
' Write the total number of items in the folder to the console
Console.WriteLine($"Total items: {folderInfo.ContentCount}")
' Write the count of unread items in the folder to the console
Console.WriteLine($"Total unread items: {folderInfo.ContentUnreadCount}")
' Enumerate through each message in the current folder
For Each messageInfo In folderInfo.EnumerateMessages()
' Write the subject of the message to the console
Console.WriteLine($"Subject: {messageInfo.Subject}")
' Extract the full message object from the messageInfo
Dim msg As MailItem = pst.ExtractMessage(messageInfo)
' Save the message as a .msg file, using its subject as the filename
msg.Save($"{msg.Subject}.msg")
Next
Next
End Using

Constructor & Destructor Documentation

◆ PersonalStorage()

Aspose::Email::Storage::Pst::PersonalStorage::PersonalStorage ( Exceptions::TraversalExceptionsCallback  callback)

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

Parameters
callbackThe exception callback.

◆ ~PersonalStorage()

virtual Aspose::Email::Storage::Pst::PersonalStorage::~PersonalStorage ( )
protectedvirtual

Member Function Documentation

◆ AddAttachmentToMessage() [1/4]

void Aspose::Email::Storage::Pst::PersonalStorage::AddAttachmentToMessage ( System::SharedPtr< MessageInfo messageInfo,
System::String  filePath 
)

Adds an attachment to the specified message using the file located at the provided path.

Parameters
messageInfoThe MessageInfo object representing the target message.
filePathThe full path to the file to be added as an attachment.
Exceptions
ArgumentNullExceptionThrown if messageInfo or filePath is null or empty.
FileNotFoundExceptionThrown if the file specified by filePath does not exist.

◆ AddAttachmentToMessage() [2/4]

void Aspose::Email::Storage::Pst::PersonalStorage::AddAttachmentToMessage ( System::SharedPtr< MessageInfo messageInfo,
System::String  name,
System::SharedPtr< System::IO::Stream >  stream 
)

Adds an attachment to the specified message using the provided stream as attachment content.

Parameters
messageInfoThe MessageInfo object representing the target message.
nameThe name of the attachment to add.
streamThe stream containing the attachment data.
Exceptions
ArgumentNullExceptionThrown if messageInfo , name , or stream is null or empty.

The provided stream is not closed or disposed by this method.

◆ AddAttachmentToMessage() [3/4]

void Aspose::Email::Storage::Pst::PersonalStorage::AddAttachmentToMessage ( System::String  entryId,
System::String  filePath 
)

Adds an attachment to the message identified by the specified entry ID using the file located at the provided path.

Parameters
entryIdThe entry ID of the target message.
filePathThe full path to the file to be added as an attachment.
Exceptions
ArgumentNullExceptionThrown if entryId or filePath is null or empty.
FileNotFoundExceptionThrown if the file specified by filePath does not exist.

◆ AddAttachmentToMessage() [4/4]

void Aspose::Email::Storage::Pst::PersonalStorage::AddAttachmentToMessage ( System::String  entryId,
System::String  name,
System::SharedPtr< System::IO::Stream >  stream 
)

Adds an attachment to the message identified by the specified entry ID using the provided stream.

Parameters
entryIdThe entry ID of the target message.
nameThe name of the attachment to add.
streamThe stream containing the attachment data.
Exceptions
ArgumentNullExceptionThrown if entryId , name , or stream is null or empty.

The provided stream is not closed or disposed by this method.

◆ Cancel()

void Aspose::Email::Storage::Pst::PersonalStorage::Cancel ( )

This method used to interrupt a split operation.

◆ ChangeMessage()

void Aspose::Email::Storage::Pst::PersonalStorage::ChangeMessage ( System::String  entryId,
System::SharedPtr< Mapi::MapiPropertyCollection updatedProperties 
)

Changes the message properties.

Parameters
entryIdThe entry identifier of message.
updatedPropertiesThe updated properties.
Exceptions
System::NotImplementedExceptionThe ANSI file version editing is not implemented.
System::InvalidOperationExceptionThe PST is open for reading only. or The entryId is incorrect.
System::ArgumentNullExceptionentryIdCollection;The collection of entry ids cannot be null. or updatedProperties;The collection of properties cannot be null.
InvalidOperationExceptionThrown when attempting to modify a PST file that is open for reading only.
NotImplementedExceptionThrown when attempting to edit the ANSI file version.
ArgumentNullExceptionThrown when entry id is null.
NotImplementedExceptionThrown when property collection is null.

◆ CloneFolderStructure()

System::SharedPtr<PersonalStorage> Aspose::Email::Storage::Pst::PersonalStorage::CloneFolderStructure ( System::String  fileName,
System::SharedPtr< System::Collections::Generic::Dictionary< uint32_t, uint32_t >>  table 
)

Clones the folder structure.

Returns
Personal storage.

◆ ConvertTo()

void Aspose::Email::Storage::Pst::PersonalStorage::ConvertTo ( FileFormat  format)

Converts the current object to the specified format.

It is used for the fast OST to PST conversion. The method doesn't support conversion of OST created by MS Office 2013 and later versions. To convert an OST of later version, create a new PST and use the MergeWith(Stream[]) method.

Parameters
formatThe FileFormat to convert the current object to.

◆ Create() [1/3]

static System::SharedPtr<PersonalStorage> Aspose::Email::Storage::Pst::PersonalStorage::Create ( System::SharedPtr< System::IO::Stream >  stream,
FileFormatVersion  version 
)
static

Creates the PST in a stream.

Note, only Unicode file version creation is supported now.

Parameters
streamThe stream in which PST is created.
versionThe PST file version.
Returns
A PersonalStorage object that represents the new PST.
Exceptions
NotImplementedExceptionthrows if ANSI file version is created
ArgumentNullExceptionthrows if stream is null

◆ Create() [2/3]

static System::SharedPtr<PersonalStorage> Aspose::Email::Storage::Pst::PersonalStorage::Create ( System::SharedPtr< System::IO::Stream >  stream,
FileFormatVersion  version,
bool  leaveStreamOpen 
)
static

Creates the PST in a stream.

Note, only Unicode file version creation is supported now.

Parameters
streamThe stream in which PST is created.
versionThe PST file version.
leaveStreamOpenLeave stream open when PersonalStorage is disposed.
Returns
A PersonalStorage object that represents the new PST.
Exceptions
NotImplementedExceptionthrows if ANSI file version is created
ArgumentNullExceptionthrows if stream is null

◆ Create() [3/3]

static System::SharedPtr<PersonalStorage> Aspose::Email::Storage::Pst::PersonalStorage::Create ( System::String  fileName,
FileFormatVersion  version 
)
static

Creates the new PST file with the specified file name.

Note, only Unicode file version creation is supported now.

Parameters
fileNameThe full name of the file.
versionThe PST file version.
Returns
A PersonalStorage object that represents the new PST.
Exceptions
NotImplementedExceptionthrows if ANSI file version is created
ArgumentNullExceptionthrows if file name is null or empty

◆ CreateFolderMapping()

System::SharedPtr<PersonalStorage> Aspose::Email::Storage::Pst::PersonalStorage::CreateFolderMapping ( System::SharedPtr< System::Collections::Generic::Dictionary< uint32_t, uint32_t >>  table)

Clones the folder structure.

Returns
Personal storage.

◆ CreatePredefinedFolder() [1/2]

System::SharedPtr<FolderInfo> Aspose::Email::Storage::Pst::PersonalStorage::CreatePredefinedFolder ( System::String  name,
StandardIpmFolder  defaultFolder 
)

Creates the standard interpersonal message (IPM) folder.

Parameters
nameThe name of folder.
defaultFolderThe value of StandardIpmFolder enumeration.
Returns
A FolderInfo object that represents a standard IPM folder.
Exceptions
InvalidOperationExceptionThrown when attempting to modify a PST file that is open for reading only.
NotImplementedExceptionThrown when attempting to edit the ANSI file version.
InvalidOperationExceptionThrown when standard folder already exists.
NotImplementedExceptionThrown when attempting to edit the OST file format.

◆ CreatePredefinedFolder() [2/2]

System::SharedPtr<FolderInfo> Aspose::Email::Storage::Pst::PersonalStorage::CreatePredefinedFolder ( System::String  name,
StandardIpmFolder  defaultFolder,
bool  createHierarchy 
)

Creates the standard interpersonal message (IPM) folder.

Parameters
nameThe name of folder.
defaultFolderThe value of StandardIpmFolder enumeration.
createHierarchyif set to true, it is possible to create a folder hierarchy using string notation. Backslash ('\') is used as path separator.
Returns
A FolderInfo object that represents a standard IPM folder.
Exceptions
NotImplementedExceptionthrows, if a PST file version is ANSI.

◆ DeleteItem()

void Aspose::Email::Storage::Pst::PersonalStorage::DeleteItem ( System::String  entryId)

Deletes the item (folder or message) by it's entryId

Parameters
entryId
Exceptions
NotImplementedExceptionthrows, if a PST file version is ANSI.
ArgumentNullExceptionthrows, if entryId is null.
InvalidOperationExceptionthrows, when trying to delete the root folder

◆ Dispose() [1/2]

void Aspose::Email::Storage::Pst::PersonalStorage::Dispose ( )
override

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

◆ Dispose() [2/2]

virtual void Aspose::Email::Storage::Pst::PersonalStorage::Dispose ( bool  disposing)
protectedvirtual

Releases unmanaged and - optionally - managed resources.

Parameters
disposingtrue to release both managed and unmanaged resources; false to release only unmanaged resources.

◆ EnumerateMessages() [1/2]

System::SharedPtr<System::Collections::Generic::IEnumerable<System::SharedPtr<MessageInfo> > > Aspose::Email::Storage::Pst::PersonalStorage::EnumerateMessages ( System::String  entryId)

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

Parameters
entryIdThe string that represents a parent folder entry ID.
Returns
System::Collections::Generic::IEnumerable<T>, that represents an enumerator that iterates through a messages in folder.

◆ EnumerateMessages() [2/2]

System::SharedPtr<System::Collections::Generic::IEnumerable<System::SharedPtr<MessageInfo> > > Aspose::Email::Storage::Pst::PersonalStorage::EnumerateMessages ( System::String  entryId,
int32_t  startIndex,
int32_t  count 
)

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

Parameters
entryIdThe string that represents a parent folder entry ID.
startIndexThe start message index.
countThe number of messages that will be retrieved.
Returns
System::Collections::Generic::IEnumerable<T>, that represents an enumerator that iterates through a messages in folder.

◆ ExtractAttachments() [1/2]

System::SharedPtr<Mapi::MapiAttachmentCollection> Aspose::Email::Storage::Pst::PersonalStorage::ExtractAttachments ( System::SharedPtr< MessageInfo messageInfo)

Extracts the attachments.

Parameters
messageInfoThe message information.
Returns
The MapiAttachmentCollection that represents the collection of attachments.

◆ ExtractAttachments() [2/2]

System::SharedPtr<Mapi::MapiAttachmentCollection> Aspose::Email::Storage::Pst::PersonalStorage::ExtractAttachments ( System::String  entryId)

Extracts the attachments.

Parameters
entryIdThe message entryId.
Returns
The MapiAttachmentCollection that represents the collection of attachments.

◆ ExtractMessage() [1/3]

System::SharedPtr<Mapi::MapiMessage> Aspose::Email::Storage::Pst::PersonalStorage::ExtractMessage ( System::ArrayPtr< uint8_t >  entryId)

Get the message from PST.

Parameters
entryIdEntryId of message.
Returns
A MapiMessage object.

◆ ExtractMessage() [2/3]

System::SharedPtr<Mapi::MapiMessage> Aspose::Email::Storage::Pst::PersonalStorage::ExtractMessage ( System::SharedPtr< MessageInfo messageInfo)

Get the message from PST.

Parameters
messageInfoA MessageInfo object that represents information about message.
Returns
A MapiMessage object.

◆ ExtractMessage() [3/3]

System::SharedPtr<Mapi::MapiMessage> Aspose::Email::Storage::Pst::PersonalStorage::ExtractMessage ( System::String  entryId)

Get the message from PST.

Parameters
entryIdString representation of EntryId.
Returns
A MapiMessage object.

◆ ExtractProperty()

System::SharedPtr<Mapi::MapiProperty> Aspose::Email::Storage::Pst::PersonalStorage::ExtractProperty ( System::ArrayPtr< uint8_t >  entryId,
int64_t  tag 
)

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

If a property is not found, null is returned.

Parameters
entryIdThe entry id of item.
tagThe property tag.
Returns
The MapiProperty.

◆ ExtractRecipients() [1/2]

System::SharedPtr<Mapi::MapiRecipientCollection> Aspose::Email::Storage::Pst::PersonalStorage::ExtractRecipients ( System::SharedPtr< MessageInfo messageInfo)

Extracts the recipients.

Parameters
messageInfoThe message information.
Returns
The MapiRecipientCollection that represents the collection of recipients.

◆ ExtractRecipients() [2/2]

System::SharedPtr<Mapi::MapiRecipientCollection> Aspose::Email::Storage::Pst::PersonalStorage::ExtractRecipients ( System::String  entryId)

Extracts the recipients.

Parameters
entryIdThe message entryId.
Returns
The MapiRecipientCollection that represents the collection of recipients.

◆ FindAndExtractSoftDeletedItems()

System::SharedPtr<System::Collections::Generic::IList<System::SharedPtr<RestoredItemEntry> > > Aspose::Email::Storage::Pst::PersonalStorage::FindAndExtractSoftDeletedItems ( )

Finds and extracts soft-deleted messages from the PST.

Returns
A list of RestoredItemEntry objects, each containing a soft-deleted message and the folder Id it was originally located in.

◆ FindMessages()

System::SharedPtr<System::Collections::Generic::IList<System::String> > Aspose::Email::Storage::Pst::PersonalStorage::FindMessages ( System::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
parentEntryIdEntry id of the parent folder.
Returns
Collection of entry Ids.

◆ FindSubfolders()

System::SharedPtr<System::Collections::Generic::IList<System::String> > Aspose::Email::Storage::Pst::PersonalStorage::FindSubfolders ( System::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
parentEntryIdEntry id of the parent folder.
Returns
Collection of entry Ids.

◆ FromFile() [1/3]

static System::SharedPtr<PersonalStorage> Aspose::Email::Storage::Pst::PersonalStorage::FromFile ( System::String  fileName)
static

Load PST from file.

Parameters
fileNameName of .pst file.
Returns
A PersonalStorage object that represents the current PST.

By default, the pst will support writing.

◆ FromFile() [2/3]

static System::SharedPtr<PersonalStorage> Aspose::Email::Storage::Pst::PersonalStorage::FromFile ( System::String  fileName,
bool  writable 
)
static

Load PST from file.

Parameters
fileNameName of .pst file.
writableif 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.

◆ FromFile() [3/3]

static System::SharedPtr<PersonalStorage> Aspose::Email::Storage::Pst::PersonalStorage::FromFile ( System::String  fileName,
System::SharedPtr< PersonalStorageLoadOptions loadOptions 
)
static

Load PST from file.

Parameters
fileNameName of .pst file.
loadOptionsThe load options.
Returns
A PersonalStorage object that represents the current PST.
Exceptions
ArgumentNullExceptionfileName - File name can not be null or empty
ArgumentExceptionPersonalStorageLoadOptions.LeaveStreamOpen can not be true.

◆ FromStream() [1/3]

static System::SharedPtr<PersonalStorage> Aspose::Email::Storage::Pst::PersonalStorage::FromStream ( System::SharedPtr< System::IO::Stream >  stream)
static

Load PST from stream.

Parameters
streamThe System.IO.Stream.
Returns
A PersonalStorage object that represents the current PST.

By default, the pst will support writing.

◆ FromStream() [2/3]

static System::SharedPtr<PersonalStorage> Aspose::Email::Storage::Pst::PersonalStorage::FromStream ( System::SharedPtr< System::IO::Stream >  stream,
bool  writable 
)
static

Load PST from stream.

Parameters
streamThe System.IO.Stream.
writableif 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() [3/3]

static System::SharedPtr<PersonalStorage> Aspose::Email::Storage::Pst::PersonalStorage::FromStream ( System::SharedPtr< System::IO::Stream >  stream,
System::SharedPtr< PersonalStorageLoadOptions loadOptions 
)
static

Load PST from stream.

Parameters
streamThe System.IO.Stream.
loadOptionsThe load options.
Returns
A PersonalStorage object that represents the current PST.

◆ get_CanWrite()

bool Aspose::Email::Storage::Pst::PersonalStorage::get_CanWrite ( )

Gets a value indicating whether the current pst supports writing.

◆ get_Format()

FileFormat Aspose::Email::Storage::Pst::PersonalStorage::get_Format ( )

Gets the file format.

FileFormat that specifies file format.

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

◆ get_IsUnicode()

bool Aspose::Email::Storage::Pst::PersonalStorage::get_IsUnicode ( )

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

◆ get_RootFolder()

System::SharedPtr<FolderInfo> Aspose::Email::Storage::Pst::PersonalStorage::get_RootFolder ( ) const

Gets the root folder of PST.

FolderInfo that represents a root folder.

◆ get_Store()

System::SharedPtr<MessageStore> Aspose::Email::Storage::Pst::PersonalStorage::get_Store ( ) const

Gets the PST message store.

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

◆ GetCategories()

System::SharedPtr<System::Collections::Generic::ListExt<System::SharedPtr<PstItemCategory> > > Aspose::Email::Storage::Pst::PersonalStorage::GetCategories ( )

Retrieves a list of PST item categories, each containing a name and associated color.

Returns
A List<PstItemCategory> containing all the available categories. The list will be non-empty if there is at least one item in the store that has the category assigned to it. If no categories are found or an error occurs, the list may be empty.

◆ GetFolderById() [1/2]

System::SharedPtr<FolderInfo> Aspose::Email::Storage::Pst::PersonalStorage::GetFolderById ( System::ArrayPtr< uint8_t >  entryId)

Gets the personal folder from PST.

Parameters
entryIdThe Entry id.
Returns
A FolderInfo object.

◆ GetFolderById() [2/2]

System::SharedPtr<FolderInfo> Aspose::Email::Storage::Pst::PersonalStorage::GetFolderById ( System::String  entryIdString)

Gets the personal folder from PST.

Parameters
entryIdStringString representation of entry ID.
Returns
A FolderInfo object.

◆ GetParentFolder() [1/2]

System::SharedPtr<FolderInfo> Aspose::Email::Storage::Pst::PersonalStorage::GetParentFolder ( System::ArrayPtr< uint8_t >  entryId)

Gets the parent folder of message.

Parameters
entryIdEntry Id of message or folder.
Returns
The parent folderFolderInfo of message.

◆ GetParentFolder() [2/2]

System::SharedPtr<FolderInfo> Aspose::Email::Storage::Pst::PersonalStorage::GetParentFolder ( System::String  entryIdString)

Finds and enumerates all soft-deleted items.

Returns
An enumerable collection of RestoredItemEntry objects, each containing a soft-deleted message and the folder Id it was originally located in.

Gets the parent folder of message.

Parameters
entryIdStringString representation of Entry Id of message or folder.
Returns
The parent folderFolderInfo of message.

◆ GetPredefinedFolder()

System::SharedPtr<FolderInfo> Aspose::Email::Storage::Pst::PersonalStorage::GetPredefinedFolder ( StandardIpmFolder  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
defaultFolderThe value of StandardIpmFolder enumeration.
Returns
A FolderInfo object that represents a standard IPM folder.

◆ GetVentureLicenseState()

VentureLicenseState Aspose::Email::Storage::Pst::PersonalStorage::GetVentureLicenseState ( )

◆ Load() [1/2]

bool Aspose::Email::Storage::Pst::PersonalStorage::Load ( System::SharedPtr< System::IO::Stream >  stream)

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

Parameters
streamThe System.IO.Stream.
Returns
'true' if the file has been loaded successfully and further traversal is possible; otherwise, false.

◆ Load() [2/2]

bool Aspose::Email::Storage::Pst::PersonalStorage::Load ( System::String  fileName)

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

Parameters
fileNameThe name of .pst file.
Exceptions
ArgumentNullExceptionfileName - File name can not be null or empty
Returns
'true' if the file has been loaded successfully and further traversal is possible; otherwise, false.

◆ MergeWith() [1/2]

void Aspose::Email::Storage::Pst::PersonalStorage::MergeWith ( System::ArrayPtr< System::SharedPtr< System::IO::Stream >>  sourceStreams)

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

Parameters
sourceStreamsThe source streams.
Exceptions
ArgumentNullException"Throws when the stream collection is null."
ArgumentException"Throws when the stream in collection is null."

◆ MergeWith() [2/2]

void Aspose::Email::Storage::Pst::PersonalStorage::MergeWith ( System::ArrayPtr< System::String >  sourceFileNames)

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

Parameters
sourceFileNamesThe source file names.
Exceptions
ArgumentNullException"Throws when the filename collection is null."
ArgumentException"Throws when the filename in collection is null or empty."

◆ MoveItem() [1/2]

void Aspose::Email::Storage::Pst::PersonalStorage::MoveItem ( System::SharedPtr< FolderInfo folder,
System::SharedPtr< FolderInfo newFolder 
)

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

Parameters
folderThe folder to move.
newFolderThe new parent folder.
Exceptions
ArgumentNullExceptionThrown when message is null.
ArgumentNullExceptionThrown when new folder is null.
NotImplementedExceptionThrown when attempting to edit the ANSI file version.
InvalidOperationExceptionThrown when there is an attempt to move the root folder, which is not a valid operation because a root folder should maintain its position in the hierarchy.
InvalidOperationExceptionThrown when there is an attempt to move a folder into itself.
InvalidOperationExceptionThrown when there is an attempt to move a folder into one of its own subfolders.

◆ MoveItem() [2/2]

void Aspose::Email::Storage::Pst::PersonalStorage::MoveItem ( System::SharedPtr< MessageInfo message,
System::SharedPtr< FolderInfo newFolder 
)

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

Parameters
messageThe message to move.
newFolderThe new folder for the message.
Exceptions
ArgumentNullExceptionThrown when message is null.
ArgumentNullExceptionThrown when new folder is null.
NotImplementedExceptionThrown when attempting to edit the ANSI file version.

◆ OnStorageProcessed()

void Aspose::Email::Storage::Pst::PersonalStorage::OnStorageProcessed ( System::SharedPtr< StorageProcessedEventArgs e)

Raises the E:ChunkCreated event.

Parameters
eThe StorageProcessedEventArgs instance containing the event data.

◆ SaveAs() [1/2]

void Aspose::Email::Storage::Pst::PersonalStorage::SaveAs ( System::SharedPtr< System::IO::Stream >  stream,
FileFormat  format 
)

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

It is used for the fast OST to PST conversion. The method doesn't support conversion of OST created by MS Office 2013 and later versions. To convert an OST of later version, create a new PST and use the MergeWith(Stream[]) method.

Parameters
streamThe stream to be saved.
formatThe FileFormat is to be used.

◆ SaveAs() [2/2]

void Aspose::Email::Storage::Pst::PersonalStorage::SaveAs ( System::String  fileName,
FileFormat  format 
)

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

It is used for the fast OST to PST conversion. The method doesn't support conversion of OST created by MS Office 2013 and later versions. To convert an OST of later version, create a new PST and use the MergeWith(string[]) method.

Parameters
fileNameThe name of the file to be saved.
formatThe FileFormat is to be used when saving a file.

◆ SaveMessageToStream()

void Aspose::Email::Storage::Pst::PersonalStorage::SaveMessageToStream ( System::String  entryId,
System::SharedPtr< System::IO::Stream >  stream 
)

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

Parameters
entryIdThe entry id.
streamThe stream for writing.

◆ SplitInto() [1/4]

void Aspose::Email::Storage::Pst::PersonalStorage::SplitInto ( int64_t  chunkSize,
System::String  partFileNamePrefix,
System::String  path 
)

Splits the pst storage into less sized parts.

Parameters
chunkSizeThe approximate size of a chunk in bytes.
pathThe folder path where chunks will be created.
partFileNamePrefixThe prefix to be added to the filename of each part of pst. If provided, the prefix will be added to the beginning of each file name. If not provided (null or empty), the pst parts will be created without a prefix.

The pst file names are produced using the following template: {prefix}_part{number}.pst

  • {prefix}: The filename prefix provided by the partFileNamePrefix parameter. If not provided, this part will be omitted.
  • {number}: The number of the chunk file.
Exceptions
ArgumentExceptionThrows when the path parameter is null or empty.
ArgumentExceptionThrows when the chunk size is less then the minimum size of pst file.

◆ SplitInto() [2/4]

void Aspose::Email::Storage::Pst::PersonalStorage::SplitInto ( int64_t  chunkSize,
System::String  path 
)

Splits the pst storage into less sized parts.

Parameters
chunkSizeThe approximate size of a chunk in bytes.
pathThe folder path where chunks will be created.
Exceptions
ArgumentExceptionThrows when the path parameter is null or empty.
ArgumentExceptionThrows when the chunk size is less then the minimum size of pst file.

◆ SplitInto() [3/4]

void Aspose::Email::Storage::Pst::PersonalStorage::SplitInto ( System::SharedPtr< System::Collections::Generic::IList< System::SharedPtr< Tools::Search::MailQuery >>>  criteria,
System::String  partFileNamePrefix,
System::String  path 
)

Splits the pst storage based on criteria.

Parameters
criteriaThe collection of MailQuery that represents criteria of pst splitting.
pathThe folder path where chunks will be created.

///

Parameters
partFileNamePrefixThe prefix to be added to the filename of each part of pst. If provided, the prefix will be added to the beginning of each file name. If not provided (null or empty), the pst parts will be created without a prefix.

The pst file names are produced using the following template: {prefix}_part{number}.pst

  • {prefix}: The filename prefix provided by the partFileNamePrefix parameter. If not provided, this part will be omitted.
  • {number}: The number of the chunk file.
Exceptions
ArgumentExceptionThrows when the path parameter is null or empty.

◆ SplitInto() [4/4]

void Aspose::Email::Storage::Pst::PersonalStorage::SplitInto ( System::SharedPtr< System::Collections::Generic::IList< System::SharedPtr< Tools::Search::MailQuery >>>  criteria,
System::String  path 
)

Splits the pst storage based on criteria.

Parameters
criteriaThe collection of MailQuery that represents criteria of pst splitting.
pathThe folder path where chunks will be created.
Exceptions
ArgumentExceptionThrows when the path parameter is null or empty.

◆ TryToGetFolderById()

bool Aspose::Email::Storage::Pst::PersonalStorage::TryToGetFolderById ( System::String  entryIdString,
System::SharedPtr< FolderInfo > &  folder 
)

Gets the folder associated with the specified entry ID.

Parameters
entryIdStringThe string that represented the entry ID.
folderWhen this method returns true, contains the FolderInfo object associated with the specified ID.
Returns
true if the folder is successfully found; otherwise, false.

◆ TryToSaveMessage()

System::SharedPtr<SaveResult> Aspose::Email::Storage::Pst::PersonalStorage::TryToSaveMessage ( System::String  entryId,
System::SharedPtr< System::IO::Stream >  stream 
)

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

Parameters
entryIdThe entry id.
streamThe stream for writing.
Returns
The SaveResult that represents the result of item saving.

Member Data Documentation

◆ ItemMoved

System::Event<void(System::SharedPtr<System::Object>, System::SharedPtr<Aspose::Email::Storage::Pst::ItemMovedEventArgs>)> Aspose::Email::Storage::Pst::PersonalStorage::ItemMoved

Occurs when an item is moved to the another folder.

◆ pstDoer

System::SharedPtr<PstDoer> Aspose::Email::Storage::Pst::PersonalStorage::pstDoer

The pst reader.

◆ StorageProcessed

System::Event<void(System::SharedPtr<System::Object>, System::SharedPtr<Aspose::Email::Storage::Pst::StorageProcessedEventArgs>)> Aspose::Email::Storage::Pst::PersonalStorage::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.

◆ StorageProcessing

System::Event<void(System::SharedPtr<System::Object>, System::SharedPtr<Aspose::Email::Storage::Pst::StorageProcessingEventArgs>)> Aspose::Email::Storage::Pst::PersonalStorage::StorageProcessing

Occurs before the srorage is processed. The event is raised before processing the next storage in merging or splitting operations.

@ Read
PersonalStorage(Exceptions::TraversalExceptionsCallback callback)
Initializes a new instance of the PersonalStorage class. Allows setting a callback method for handlin...