Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
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 IAppointmentinterface object, as follows:

    Copy Code
    IAppointment *pAppt = NULL;
    
  3. Call IPOutlookApp::CreateItemon the Outlook Mobile application object:

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

    Copy Code
    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:

    Copy Code
    polApp->SystemTimeToVariantTime(&st, &date);
    
  6. Set the Appointment Startproperty:

    Copy Code
    pAppt->put_Start(date);
    
  7. Set the Appointment Subjectproperty:

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

    Copy Code
    pAppt->Save();
    

    The Appointmentitem is added to the Outlook Mobile database.

Example

The following code example demonstrates how to create an IAppointmentinterface 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.
Copy Code
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