共用方式為


Establishing a POOM Session

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

Before you can create and manipulate PIM items, you must first create an instance of the Outlook Mobile application object, and then use it to establish a POOM session, which opens a connection to the PIM database.

To establish an POOM session

  1. Declare and initialize a pointer to the IPOutlookApp interface object:

    IPOutlookApp * g_polApp = NULL;
    
  2. Initialize COM:

    CoInitializeEx( NULL, 0);
    
  3. Create an Application class COM server object:

    CoCreateInstance(CLSID_Application, NULL, CLSCTX_INPROC_SERVER, IID_IUnknown, (void **)&g_pUnknown);
    
  4. Get a reference to the Outlook Mobile application interface object:

    g_pUnknown->QueryInterface(IID_IPOutlookApp, (void**)&g_polApp);
    
  5. Logon to the Outlook Mobile COM server:

    g_polApp->Logon(NULL);
    

Example

The following code example demonstrates how to create the Outlook Mobile application object and then use it to establish a POOM session.

Note

To make the following code example easier to read, security checking and error handling are not included. This code example should not be used in a release configuration unless it has been modified to include them.

BOOL InitPoom(void)
{
    IPOutlookApp * g_polApp   = NULL;
    IUnknown     * g_pUnknown = NULL;
    BOOL             bSuccess = FALSE;

    hr = CoInitializeEx(NULL, 0);
    hr = CoCreateInstance(CLSID_Application, NULL, CLSCTX_INPROC_SERVER, IID_IUnknown, (void **)&g_pUnknown);
    hr = g_pUnknown->QueryInterface(IID_IPOutlookApp, (void**)&g_polApp);

    hr = g_polApp->Logon(NULL);

    bSuccess = TRUE;
    return bSuccess;
}

To make the code example easier to read, security checking and error handling are not included.

This code example should not be used in a release configuration unless it has been modified to include them.

Compiling the Code

  • Include Header File: PimStore.h
  • Linker Dependency: PimStore.lib

See Also

Reference

IPOutlookApp::Logoff

Other Resources

Pocket Outlook Object Model Common Tasks
Pocket Outlook Object Model Application Development