Creating a Recurring Appointment

Windows Mobile 6.5
A version of this page is also available for
4/8/2010

Any appointment becomes a recurring appointment when you retrieve its RecurrencePattern object, set the recurrence values, and then save the Appointment item to the data store. The following procedure demonstrates how to create an appointment that recurs every Monday at 8:30 P.M.

  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. Create a PIM item:

    polApp->CreateItem(olAppointmentItem, (IDispatch**)&pAppt);
    
  4. Create a SYSTEMTIME object, and initialize it with a start date:

    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("Recurring Appointment"));
    
  8. Set the appointment recurrence pattern:

    pAppt->GetRecurrencePattern(&pRec);
    pRec->put_RecurrenceType(olRecursWeekly);
    pRec->put_DayOfWeekMask(olMonday);
    pRec->put_NoEndDate(VARIANT_TRUE);
    
  9. Add the recurring appointment to the appointment collection:

    pAppt->Save();
    

The following code example demonstrates how to create a recurring appointment.

Aa919961.note(en-us,MSDN.10).gifNote:
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 CreateRecurringApt(IPOutlookApp *polApp)
{
    IAppointment       * pAppt;
    IRecurrencePattern * pRec;
    SYSTEMTIME           st;
    DATE                 date;

    // Create an Appointment item.
    polApp->CreateItem(olAppointmentItem, (IDispatch**)&pAppt);

    // Set the Appointment's start date and time.
    memset(&st, 0, sizeof(SYSTEMTIME));

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

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

    // Set the Appointment's subject.
    pAppt->put_Subject(TEXT("Test Recurring Appointment"));

    // Set the Appointment's Recurrence Pattern.
    pAppt->GetRecurrencePattern(&pRec);

    pRec->put_RecurrenceType(olRecursWeekly);
    pRec->put_DayOfWeekMask(olMonday);
    pRec->put_NoEndDate(VARIANT_TRUE);

    // Add the Recurring Appointment to the Appointment Collection.
    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.

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

Community Additions

Show: