Code Example: Creating a Recurring Appointment
9/8/2008
O seguinte exemplo de código Visual C++ demonstra como criar um compromisso recorrente. Este compromisso irá ocorrer todas as segundas-feiras em 8:30 PM.
Observação
Pressupõe-se que você já tiver criado um objeto IPOutlookApp e tiver feito em uma sessão POOM.Para tornar o exemplo de código mais fácil para ler, verificação de segurança e manipulação de erro não estão incluídos.This code example should not be used in a release configuration unless it has been modified to include them.
IAppointment * pAppt;
IRecurrencePattern * pRec;
DATE date;
SYSTEMTIME st;
// Call CreateItem to create an item directly from the Application object.
polApp->CreateItem(olAppointmentItem, (IDispatch**)&pAppt);
// Convert Monday, 5/10/2007 at 8:30 PM, to a DATE object.
memset (&st, 0, sizeof(SYSTEMTIME));
st.wMonth = 5;
st.wDay = 10;
st.wYear = 2007;
st.wHour = 20.5;
polApp->SystemTimeToVariantTime(&st, &date);
// Set the subject and the start date.
pAppt->put_Subject (TEXT("Recurring Appointment"));
pAppt->put_Start(date);
// Set the recurrence pattern.
pAppt->GetRecurrencePattern(&pRec);
pRec->put_RecurrenceType(olRecursWeekly);
pRec->put_DayOfWeekMask(olMonday);
pRec->put_NoEndDate(VARIANT_TRUE);
// Save the Appointment.
pAppt->Save();
// Release resources.
pRec->Release();
pAppt->Release();
O seguinte exemplo de código Visual Basic mostra como criar um compromisso recorrente.
' olAppointmentItem is replaced with 1
Set pAppt = polApp.CreateItem (1)
pAppt.Subject = "Recurring Appointment"
pAppt.Start = #5/10/2007 8:30 PM#
' olRecursWeekly is replaced with 1 and olMonday is replaced with 2.
Set pRec = pAppt.GetRecurrencePattern
pRec.RecurrenceType = 1
pRec.DayOfWeekMask = 2
pRec.NoEndDate = True
' Save the Appointment
pAppt.Save
See Also
Tasks
Creating a Recurring Appointment