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 VSTO add-in projects for Outlook. 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();
            }
        }

Working with Calendar Items
Getting Started Programming VSTO Add-ins
How to: Programmatically Create Appointments
How to: Programmatically Create a Custom Calendar
How to: Programmatically Create a Meeting Request

Show: