wieseljonas / java-libpst

Automatically exported from code.google.com/p/java-libpst
1 stars 1 forks source link

Sample Code to fetch Appointments from Outlook #69

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

I need to fetch all the appointments present in my outlook calendar.( The 
calendar appointments have been exported as .pst files). Can any one please 
help me by supplying code for fetching the appointments from the pst file.

Thanks in advance.

Original issue reported on code.google.com by vinaykum...@gmail.com on 17 Feb 2014 at 4:59

GoogleCodeExporter commented 9 years ago
Hi, here is my example:

    public Synchro(String filename) {
        try {
            PSTFile pstFile = new PSTFile(filename);
            System.out.println(pstFile.getMessageStore().getDisplayName());
            processFolder(pstFile.getRootFolder());
        } catch (Exception err) {
            err.printStackTrace();
        }
    }

    public void processFolder(PSTFolder folder)
            throws PSTException, java.io.IOException
    {
        // go through the folders...
        if (folder.hasSubfolders()) {
            Vector<PSTFolder> childFolders = folder.getSubFolders();
            for (PSTFolder childFolder : childFolders) {
                processFolder(childFolder);
            }
        }

        String containerClass = folder.getContainerClass();
        if ("IPF.Appointment".equals(containerClass)) {
            System.out.println(folder.getDisplayName() + " [" + folder.getContainerClass() + "]");

            PSTAppointment appointment = (PSTAppointment)folder.getNextChild();
            while (appointment != null) {
                print(appointment);
                appointment = (PSTAppointment) folder.getNextChild();
            }
        }
    }

    private void print(PSTAppointment appointment) {
        System.out.println(appointment.getSubject());
        System.out.println("\t" + appointment.getCreationTime());
        System.out.println("\t" + appointment.getAllAttendees());
    }

Original comment by misis...@gmail.com on 15 Sep 2014 at 1:08