共用方式為


尋找與會議邀請相關聯的約會專案

此範例示範如何使用 GetAssociatedAppointment (布爾) 方法來尋找與會議邀請相關聯的約會。

範例

注意事項

下列程式代碼範例是 Microsoft Office Outlook 2007 程式設計應用程式的摘錄。

MeetingItem 物件不代表約會,而是包含將約會新增至收件者行事曆之要求的訊息。 在下列程式代碼範例中,MeetingRequestExample 會在從使用者的 [收件匣] 擷取的每個 MeetingItem 上,使用 MeetingItem 物件的 GetAssociatedAppointment (Boolean) 方法。 然後會使用傳回的 AppointmentItem 物件,將約會的主旨寫入接聽程式集合的追蹤接 程式。

注意事項

請注意 ,GetAssociatedAppointment 自變數設定為 false ,因此不會將約會新增至使用者的行事曆。

If you use Visual Studio to test this code example, you must first add a reference to the Microsoft Outlook 15.0 Object Library component and specify the Outlook variable when you import the Microsoft.Office.Interop.Outlook namespace. The using statement must not occur directly before the functions in the code example but must be added before the public Class declaration. The following line of code shows how to do the import and assignment in C#.

using Outlook = Microsoft.Office.Interop.Outlook;
private void MeetingRequestsExample()
{
    Outlook.Folder folder = Application.Session.
        GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
        as Outlook.Folder;
    string filter = "[MessageClass] = " +
        "'IPM.Schedule.Meeting.Request'";
    Outlook.Items items = folder.Items.Restrict(filter);
    foreach (Outlook.MeetingItem request in items)
    {
        Outlook.AppointmentItem appt =
            request.GetAssociatedAppointment(false);
        if (appt != null)
        {
            Debug.WriteLine(appt.Subject);
        }
    }
}

另請參閱