Home : How to Access Forms Published to the Organizational Forms Library in the Exchange Server
Q137305 - HOWTO: How to Access Forms Published to the Organizational Forms Library in the Exchange Server

How to Access Forms Published to the Organizational Forms Library in the Exchange Server

 

Forms are saved in the Exchange Server as hidden messages. To access these forms, you need to have access to the system folders where these hidden messages are stored. The following code demonstrates how to access forms stored in the Organizational Forms Library using Java through J-Integra for Exchange. This code is a Java implementation of the same VB code that is found in this link: http://www.cdolive.com/cdo5.htm#OrganizationFormsLibrary

/**
 * Created by IntelliJ IDEA.
 * User: fragasa
 * Date: Mar 2, 2005
 * Time: 1:08:44 PM
 * To change this template use Options | File Templates.
 */

import com.intrinsyc.cdo.*;

public class AccessForms {

    // Modify the following variables based on your specific setup
    static String domain     = "DOMAIN";    //domain where the CDO host machine belongs
                                            //make sure it's all capitalized
    static String user       = "username";  //username of Java-Exchange user
    static String password   = "password";  //password of Java-Exchange user
    static String mailbox    = "mailbox";   //mailbox of Java-Exchange user. By MS Exchange settings,
                                            //the mailbox name is the same as the username
    static String CDOmachine = "000.000.000.000";   // IP address of the CDO host machine
                                                    // or name of the machine (e.g. "machine1")
    static String exchangeServer = "000.000.000.000"; // IP address of the Exchange Server
                                                // or name of the Exchange Server (e.g. "mailServer")

    // MAPI property to access the system folder subtree
    static final Integer PR_NON_IPM_SUBTREE_ENTRYID = new Integer(1713373442);

    // MAPI property to access the form name
    static final Integer CdoPR_DISPLAY_NAME = new Integer(805371934);

    public static void main(String[] args) {

        try {
            // Authenticate to NT domain via NTLM
            com.linar.jintegra.AuthInfo.setDefault(domain, user, password);

            // Start a MAPI Session
            Session session = new Session(CDOmachine);

            // Logon to the Exchange Server
            session.logon(null, null, new Boolean(false), new Boolean(true),
                          new Integer(0), new Boolean(true),
                          exchangeServer + "\n" + mailbox);

            // Get the "Public Folders" information store
            InfoStores infoStores = new InfoStoresProxy(session.getInfoStores());
            InfoStore infoStore = new InfoStoreProxy(infoStores.getItem("Public Folders"));

            // Get the Root ID of the non IPM subtree
            Fields fields = new FieldsProxy(infoStore.getFields());
            Field field = new FieldProxy(fields.getItem(PR_NON_IPM_SUBTREE_ENTRYID, null));
            String rootID = field.getValue().toString();

            // Get the top folder of the non IPM subtree
            Folder topFolder = new FolderProxy(session.getFolder(rootID, infoStore.getID()));

            // Get the Organization Forms Library
            Folders folders = new FoldersProxy(topFolder.getFolders());
            Folder formsRegistry = new FolderProxy(folders.getItem("EFORMS REGISTRY"));

            // Note that you can create multiple forms libraries with different names
            // This sample assumes that the name of your forms library is "Organization Forms"
            Folders folders2 = new FoldersProxy(formsRegistry.getFolders());
            Folder orgFormsFolder = new FolderProxy(folders2.getItem("Organization Forms"));

            // Once you have access to that folder, you can work with the items
            Messages messages = new MessagesProxy(orgFormsFolder.getHiddenMessages());

            // Iterate through the items in the folder
            System.out.println("The following organization forms are found: ");
            int count = ((Integer)messages.getCount()).intValue();
            for(int i=1; i<=count; i++){
                Message message = new MessageProxy(messages.getItem(new Integer(i)));
                Fields messageFields = new FieldsProxy(message.getFields());
                Field mField = new FieldProxy(messageFields.getItem(CdoPR_DISPLAY_NAME, null));
                String formName = mField.getValue().toString();
                System.out.println( "\t" + i + ". Form name - " + formName);
            }

            // log off
            session.logoff();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            com.linar.jintegra.Cleaner.releaseAll();
        }
    }
}
Related Articles
No Related Articles Available.

Article Attachments
No Attachments Available.

Related External Links
No Related Links Available.
Help us improve this article...
What did you think of this article?

poor 
1
2
3
4
5
6
7
8
9
10

 excellent
Tell us why you rated the content this way. (optional)
 
Approved Comments...
No user comments available for this article.
Created on 6/23/2006.
Last Modified on 7/10/2006.
Last Modified by No Author Name Available!.
Article has been viewed 7969 times.
Rated 5 out of 10 based on 29 votes.
Print Article
Email Article