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

Free Support Forum - aspose.com

PST code to get messages from a folder

Take a look at the code below. I am getting the same message over and over from a folder. If I have 10 messages in the inbox I get 10 messages out but they are all the same. I can not find a code sample to try other than this one. If I can get this working the other issues I have are not that critical. Thanks.

private void Get_Messages_And_Write_To_DASD()

Aspose.Email.Outlook.Pst.PersonalStorage pst = PersonalStorage.FromFile("\\TEMP\\Aspose Exchange Test PST.pst");

FolderInfoCollection folderInfoCollection = pst.RootFolder.GetSubFolders();

foreach (FolderInfo folderInfo in folderInfoCollection)


MessageInfoCollection messageInfoCollection = folderInfo.GetContents();
foreach (MessageInfo messageInfo in messageInfoCollection)


MapiMessage message = pst.ExtractMessage(messageInfo);

message.Save("\\TEMP\\Aspose Message " + folderInfo.DisplayName + " " + ix1 + ".msg");





Hi Tom,

Thank you for your interest in Aspose products.

I am afraid, I am unable to replicate your said problem on my end by using my own sample PST files. My PST files have 10 to 400+ messages and I am unable to observe the issue as mentioned in your original post. But when I tried the sample code on your provided PST, the issue occurs.

As discussed here, the problem doesn’t seem to be caused by the Aspose.Email component but due to the messages that you are adding to the PST. Moreover, I have verified that the messages starting with “WebDav” prefix are accentually of EML format. This fact doesn’t change the logic of importing these messages in PST nor their extraction.

We are currently looking into is and we will keep you posted with updates on your other thread.