Export (0) Print
Expand All

How to: Programmatically Delete Appointments

This example deletes one instance of a recurring appointment. The example assumes that an instance of a recurring appointment occurs on June 28, 2006, at 08:00.

Applies to: The information in this topic applies to application-level projects for Outlook 2013 and Outlook 2010. For more information, see Features Available by Office Application and Project Type.

private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
    Outlook.MAPIFolder calendar =
        Application.Session.GetDefaultFolder(
         Outlook.OlDefaultFolders.olFolderCalendar);

    Outlook.Items calendarItems = calendar.Items;

    Outlook.AppointmentItem item =
        calendarItems["Test Appointment"] as Outlook.AppointmentItem;

    Outlook.RecurrencePattern pattern =
        item.GetRecurrencePattern();
    Outlook.AppointmentItem itemDelete = pattern.
        GetOccurrence(new DateTime(2006, 6, 28, 8, 0, 0));

    if (itemDelete != null)
    {
        itemDelete.Delete();
    }
}
Show:
© 2015 Microsoft