by
56 7
0
7
2,100
1
Top 1% !
Popular
Famous
Easy-to-find
Specified
Refined
OpenSource
Popularity: 10030th place
Languagenimrod
LicenseMIT_X11
MethodNameRetrievePSTFolderContents
OSAndroid
OutputTypevoid

How to Reads Outlook PST File & Displays Folder or Message Information in Android Apps

This technical tip shows how to get the messages information from the Outlook PST file and display it inside .NET Applications.  Previously we have discussed how to load an Outlook PST file and browse through its folders to get folder names and the number of messages in each folder. This topic explains how to read all the folders and subfolders in a PST file and display the information about messages, including subject, sender, recipients, and so on. The Outlook PST file may contain nested folders. To access them, a recursive method is needed. Below is the complete source code of a console application that reads an Outlook PST file and displays the folder and message contents recursively.
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/796085/How-to-Reads-Outlook-PST-File---Displays?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
public void RetrievePSTFolderContents() { String strBaseFolder = Environment.getExternalStorageDirectory().getPath() + "/"; String pstFileName = strBaseFolder + "Outlook.pst"; try { // Load the Outlook PST file PersonalStorage pst = PersonalStorage.fromFile(pstFileName); // Get the root folder FolderInfo folderInfo = pst.getRootFolder(); // Call the recursive method to display the folder contents DisplayFolderContents(folderInfo, pst); } catch (Exception ex) { tx.setText(ex.getMessage()); } } private static void DisplayFolderContents(FolderInfo folderInfo, PersonalStorage pst) { // Display the folder name tx.setText(tx.getText() + "\n Folder: " + folderInfo.getDisplayName()); // Display information about messages inside this folder MessageInfoCollection messageInfoCollection = folderInfo.getContents(); for (int i = 0; i < messageInfoCollection.size(); i++) { MessageInfo messageInfo = (MessageInfo) messageInfoCollection.get(i); tx.setText(tx.getText() + "\n Subject: " + messageInfo.getSubject()); tx.setText(tx.getText() + "\n Sender: " + messageInfo.getSenderRepresentativeName()); tx.setText(tx.getText() + "\n To: " + messageInfo.getDisplayTo()); tx.setText(tx.getText() + "\n CC: " + messageInfo.getDisplayCC()); tx.setText(tx.getText() + "\n EntryID: " + messageInfo.getEntryIdString()); } // Call this method recursively for each subfolder if (folderInfo.hasSubFolders() == true) { for (int i = 0; i < folderInfo.getSubFolders().size(); i++) { FolderInfo subfolderInfo = (FolderInfo) folderInfo.getSubFolders().get(i); DisplayFolderContents(subfolderInfo, pst); } } }
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus