We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Speed of message retrieval from PST

when doing this, it is taking 1-3 seconds to extract message from PST. Is there a way to speed it up?

Dim builder As PersonalStorageQueryBuilder = New PersonalStorageQueryBuilder()
builder.SentDate.Since(CType("01/01/1970", DateTime), Aspose.Email.DateComparisonType.ByDate)
Dim messages As MessageInfoCollection = lFolder.GetContents(builder.GetQuery)
For Each msgInfo As MessageInfo In lFolder.GetContents ' In messages
'For Each eid As String In lFolder.EnumerateMessagesEntryId()
' Extract the message in MapiMessage instance
Dim msg As MapiMessage = pst.ExtractMessage(msgInfo.EntryId)

Also, there are only 20 messages in the PST.

Hi Simon,

Thank you for posting your query.

We have investigated the issue at our end with a sample PST having 50 messages and the following sample code, and it took on average no time to complete the operation. Please note that the QueryBuilder may take time based on the variation of time for search criterion specified. In addition, can you please share if you have any comparison result of our API with other vendor’s API for the same operation. This will help us compare the performance and make improvements.


PersonalStorage pst = PersonalStorage.FromFile(“2Speed.pst”);<o:p></o:p>

FolderInfo fi = pst.RootFolder.GetSubFolder("Test");

PersonalStorageQueryBuilder builder = new PersonalStorageQueryBuilder();

builder.SentDate.Since(new DateTime(1970, 1, 1));

Console.WriteLine("Builder start: " + DateTime.Now);

MessageInfoCollection coll = fi.GetContents(builder.GetQuery());

Console.WriteLine("\nTotal Messages: " + coll.Count);

Console.WriteLine("\nBuilder end: " + DateTime.Now);

Console.WriteLine("\nExtraction start: " + DateTime.Now);

int iCount = 0;

foreach (MessageInfo messageInfo in fi.EnumerateMessages())


using (FileStream fs = File.OpenWrite(iCount + ".msg"))


pst.SaveMessageToStream(messageInfo.EntryIdString, fs);


iCount += 1;


Console.WriteLine("\nExtraction end: " + DateTime.Now);

I would like to point out that the original poster is calling pst.ExtractMessage() rather than saving to a stream.

I have noticed similar issues. I have a program that scans PSTs loading and processing MapiMessage instances. By far the longest time is spent on the ExtractMessage() method. We are seeing speeds between 1 and 8 calls per second.

This wouldn’t be too bad if we could use multi-threading, but ExtractMessage fails if used without a lock in a C# Parallel.For loop.

We have considered using folderInfo.EnumerateMapiMessages() but that seems just as slow.

Is there any way to either load MapiMessage instances faster or load them in parallel?

I ran some tests on a PST using different methods to iterate over a PST. As can be seen below, the first method takes 10 seconds to iterate over the PST where the other methods take over 19 minutes. The first method uses MessageInfo instances while the other 2 use MapiMessages. Unfortunately we need to use MapiMessages.

Method 1: 9504 messages, 0 errors, 00:00:10
Method 2: 9504 messages, 0 errors, 00:19:28
Method 3: 9504 messages, 0 errors, 00:19:32

A cut down description of the code follows:

Method 1

messageInfoCollection = folderInfo.GetContents();
for (var itemIndex = 1; itemIndex <= messageInfoCollection.Count; itemIndex++)
var mailItem = messageInfoCollection[itemIndex - 1];
var subject = mailItem.Subject;

Method 2

mapiMessages = folderInfo.EnumerateMapiMessages();
foreach (MapiMessage msg in mapiMessages)
string subject = msg.Subject;

Method 3

entryIds = folderInfo.EnumerateMessagesEntryId();
foreach (var entryId in entryIds)
var extractMessage = pst.ExtractMessage(entryId);
var subject = extractMessage.Subject;

Hi Reuben,

Thank you for the detailed analysis.

The very first thing, that I would like to share, is that the API doesn’t support extracting messages in parallel/multi-threaded code. We already have a feature request logged as EMAILNET-33470 in our issue tracking system for implementation of this feature. However, it is still unresolved and yet to be considered by product team for possible implementation.

Unfortunately, as per your requirements, you have to use the ExtractMessage method as it is the only way to get the MapiMessage for usage. MessageInfo actually retrieves a subset of informaiton contained in the message and, hence, retrieval of such information is fast. At present, until EMAILNET-33470 is resolved, there seems to be no other way to extract messages more faster. Please feel free to share your feedback if any in this regard.

Hi, do you have any more information about when EMAILNET-33470 might be addressed? Thanks.

Hi Reuben,

We are sorry to share that the issue is marked for indefinite resolution time period as this requires heavy restructuring of the functionality and We won’t be able to provide solution for this in near future.