共用方式為


HOW TO:以程式設計方式刪除約會

這個範例會刪除週期性約會的執行個體。此外,此範例會假設有一個週期性約會的執行個體發生在 2006 年 6 月 28 日的 08:00。

**適用於:**本主題中的資訊適用於 Outlook 2013 和 Outlook 2010 的應用程式層級專案。如需詳細資訊,請參閱依 Office 應用程式和專案類型提供的功能

範例

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();
    }
}

請參閱

工作

HOW TO:以程式設計方式建立約會

HOW TO:以程式設計方式建立自訂行事曆

HOW TO:以程式設計方式建立會議邀請

概念

使用行事曆項目

應用程式層級增益集程式設計入門