Creating a PIM Item

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

The three PIM item types—Appointment, Task, and Contact—are the main object types in the Pocket Outlook Object Model, and the procedure for creating them is the same for all three.

To create an Appointment

  1. Create an instance of the Outlook Mobile application object and then use it to establish a POOM session. For more information, see Establishing a POOM Session.

  2. Declare and initialize a pointer to a new IAppointment interface object, as follows:

    IAppointment *pAppt = NULL;
    
  3. Call IPOutlookApp::CreateItem on the Outlook Mobile application object:

    polApp->CreateItem(olAppointmentItem, (IDispatch **)&pAppt);
    
  4. Create a SYSTEMTIME object, and initialize it with a start date of Monday, 5/10/2007 at 8:30 PM:

    memset(&st, 0, sizeof(SYSTEMTIME));
    
    st.wMonth = 5;
    st.wDay   = 10;
    st.wYear  = 2007;
    st.wHour  = 20.5;
    
  5. Convert the system time object to a Variant date/time object:

    polApp->SystemTimeToVariantTime(&st, &date);
    
  6. Set the Appointment Start property:

    pAppt->put_Start(date);
    
  7. Set the Appointment Subject property:

    pAppt->put_Subject(TEXT("Test Appointment"));
    
  8. Add the new Appointment to the Appointment collection:

    pAppt->Save();
    

    The Appointment item is added to the Outlook Mobile database.

Example

The following code example demonstrates how to create an IAppointment interface object.

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.

void AddNewAppointment(IPOutlookApp *polApp)
{
    IAppointment * pAppt = NULL;
    SYSTEMTIME     st;
    DATE           date;

    polApp->CreateItem(olAppointmentItem, (IDispatch**)&pAppt);

    memset(&st, 0, sizeof(SYSTEMTIME));

    st.wMonth = 5;
    st.wDay   = 10;
    st.wYear  = 2007;
    st.wHour  = 20.5;

    polApp->SystemTimeToVariantTime(&st, &date);

    hr = pAppt->put_Subject(TEXT("Test Appointment"));
    hr = pAppt->put_Start(date);

    hr = pAppt->Save();
}

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::CreateItem
IPOutlookApp::SystemTimeToVariantTime
OlItemType

Other Resources

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