nashie Posted January 26, 2009 Share Posted January 26, 2009 Does anyone know how to parse PST files please? I would like reliable information in relation to the PST file structure. Any resources or documentation source/s would be greatly appreciated. I've tried Googling and all that jazz but nothing useful. I need the structure rather than reading the content as this will at some point be incorporated into an application which needs to extract all emails and their attachments. Thanks in advance Dave Quote Link to comment Share on other sites More sharing options...
Uba Posted March 4, 2011 Share Posted March 4, 2011 Does anyone know how to parse PST files please? I would like reliable information in relation to the PST file structure. Any resources or documentation source/s would be greatly appreciated. I've tried Googling and all that jazz but nothing useful. I need the structure rather than reading the content as this will at some point be incorporated into an application which needs to extract all emails and their attachments. Thanks in advance Dave Much agreed, if anyone out there has any information on parseing pst files for the use of extracting emails and attachements please post!. Quote Link to comment Share on other sites More sharing options...
Uba Posted March 4, 2011 Share Posted March 4, 2011 to keep information flowing in this thread i may have found what i was looking for http://www.dimastr.com/redemption/ I will update how the trial run goes. Quote Link to comment Share on other sites More sharing options...
Uba Posted March 5, 2011 Share Posted March 5, 2011 okay so i have figured something out, the only problem is that you need outlook installed and configured with a profile. still working on a standalone solution. public static IEnumerable<MailItem> readPst(string pstFilePath, string pstName) { List<MailItem> mailItems = new List<MailItem>(); Microsoft.Office.Interop.Outlook.Application app = new Microsoft.Office.Interop.Outlook.Application(); NameSpace outlookNs = app.GetNamespace("MAPI"); // Add PST file (Outlook Data File) to Default Profile outlookNs.AddStore(pstFilePath); Microsoft.Office.Interop.Outlook.MAPIFolder rootFolder = outlookNs.Stores[pstName].GetRootFolder(); // Traverse through all folders in the PST file // TODO: This is not recursive, refactor Folders subFolders = rootFolder.Folders; foreach (Folder folder in subFolders) { Items items = folder.Items; foreach (object item in items) { if (item is MailItem) { MailItem mailItem = item as MailItem; mailItems.Add(mailItem); } } } // Remove PST file from Default Profile outlookNs.RemoveStore(rootFolder); return mailItems; } This code will retrieve all mailitems inside the pst file. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.