Comment : supprimer des rendez-vous par programmationHow to: Programmatically Delete Appointments

Cet exemple supprime une instance d’un rendez-vous périodique.This example deletes one instance of a recurring appointment. L’exemple part du principe qu’une instance d’un rendez-vous périodique se produit le 28 juin 2006 à 08:00.The example assumes that an instance of a recurring appointment occurs on June 28, 2006, at 08:00.

S’applique à : Les informations contenues dans cette rubrique s’appliquent aux projets de compléments VSTO pour Outlook.Applies to: The information in this topic applies to VSTO add-in projects for Outlook. Pour plus d’informations, consultez Fonctionnalités disponibles par type d’application et de projet Office.For more information, see Features Available by Office Application and Project Type.

ExempleExample

Private Sub ThisAddIn_Startup(ByVal sender As Object, _
    ByVal e As System.EventArgs) Handles Me.Startup

    Dim calendar As Outlook.MAPIFolder = _
        Application.Session.GetDefaultFolder( _
        Outlook.OlDefaultFolders.olFolderCalendar)

    Dim calendarItems As Outlook.Items = calendar.Items

    Dim item As Outlook.AppointmentItem = TryCast( _
        calendarItems("Test Appointment"), Outlook.AppointmentItem)

    Dim pattern As Outlook.RecurrencePattern = _
        item.GetRecurrencePattern()

    Dim itemDelete As Outlook.AppointmentItem = _
        pattern.GetOccurrence(New Date(2006, 6, 28, 8, 0, 0))

    If itemDelete IsNot Nothing Then
        itemDelete.Delete()
    End If
End Sub
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();
    }
}

Voir aussiSee Also

Utilisation des éléments de calendrier Working with Calendar Items
Getting Started Programming VSTO Add-ins Getting Started Programming VSTO Add-ins
Comment : créer des rendez-vous par programmation How to: Programmatically Create Appointments
Comment : créer par programmation un calendrier personnalisé How to: Programmatically Create a Custom Calendar
Guide pratique pour créer une demande de réunion par programmationHow to: Programmatically Create a Meeting Request