Want to disconnect or delete PST from Outlook with Jacob jar

576 views Asked by At

I am using Jacob jar file to save msg. To connect the pst i am using the below code:

ActiveXComponent ol = new ActiveXComponent("Outlook.Application");
if (ol != null) {
    try {
        System.out.println("try block....");
        Dispatch olo = ol.getObject();
        Dispatch myNamespace = Dispatch.call(olo, "GetNamespace","MAPI").toDispatch();
        Variant varNewStore = Dispatch.call(myNamespace, "AddStore",strPSTPath);
        Dispatch disAllFolders = Dispatch.call(myNamespace, "Folders").toDispatch();
        Dispatch oRootFolder = Dispatch.call(disAllFolders, "GetLast").toDispatch();
        Dispatch innerFolder = Dispatch.call(oRootFolder, "Folders","Inbox").toDispatch();
        Dispatch items = Dispatch.call(innerFolder, "Items").toDispatch()
    }
}

Now i want to delete or disconnect PST file from Outlook plz suggest me how can i achieve this functionality.

Regards, Kashif

1

There are 1 answers

0
Joe Kaisaka On

Kashif:

I don't program in Java, but I'm learning JABACO (Java To Basic Compiler) and I'm using the excellent JACOB.

In the JACOB FAQ [ http://danadler.com/jacob/jacobfaq.html ], I found this:

Hey, my Excel and/or Word process still remain, also after the Java program terminates!

Try calling ComThread.release() when you’re finished. See http://groups.yahoo.com/group/jacob-project/message/1425

I hope that I have helped.