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

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.
//your code here...//Get the Messages Information from the Outlook PST File 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); } } }


Language: Java | User: Sheraz Khan | Created: Nov 18, 2015 | Tags: Get outlook messages information display Outlook PST file content load Outlook PST file reads an Outlook PST file get Outlook messages android email API