Creating a Recurring Appointment
Any appointment becomes a recurring appointment when you retrieve its recurrence pattern object, set the recurrence values, and then save the Appointment. The following procedure demonstrates how to create an appointment that recurs every Monday at 2:00 P.M.
To create a recurring appointment
Create an instance of the Outlook Mobile application object and then use it to establish a POOM session. For more information, see How to: Establish a POOM session.
Declare and initialize a pointer to a new IAppointment interface object, as follows:
IAppointment *pAppt = NULL;
Create a PIM item:
polApp->CreateItem(olAppointmentItem, (IDispatch**)&pAppt);
Create a SYSTEMTIME object, and initialize it with a start date:
memset(&st, 0, sizeof(SYSTEMTIME)); st.wMonth = 7; st.wDay = 26; st.wYear = 2004; st.wHour = 14;
Convert the system time object to a Variant date/time object:
polApp->SystemTimeToVariantTime(&st, &date);
Set the appointment Start property:
pAppt->put_Start(date);
Set the appointment Subject property:
pAppt->put_Subject(TEXT("Recurring Appointment"));
Set the appointment 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();
Code Example
The following code example demonstrates how to create a recurring appointment.
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 CreateRecurringApt(IPOutlookApp *polApp)
{
IAppointment *pAppt;
IRecurrencePattern *pRec;
SYSTEMTIME st;
DATE date;
// Create an appointment item.
polApp->CreateItem(olAppointmentItem, (IDispatch**)&pAppt);
// Set the appointment start date and time.
memset(&st, 0, sizeof(SYSTEMTIME));
st.wMonth = 7;
st.wDay = 27;
st.wYear = 2004;
st.wHour = 14;
polApp->SystemTimeToVariantTime(&st, &date);
pAppt->put_Start(date);
// Set the appointment subject.
pAppt->put_Subject(TEXT("Recurring Appointment"));
// Set the appointment 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();
// Free resources.
pRec->Release();
pAppt->Release();
}
See Also
Pocket Outlook Object Model Application Development for Windows Mobile-based DevicesIAppointment::GetRecurrencePattern | IAppointment::Save | IRecurrencePattern | IRecurrencePattern::put_DayOfWeekMask | IRecurrencePattern::put_NoEndDate | IRecurrencePattern::put_RecurrenceType
Send Feedback on this topic to the authors