共用方式為


自動接受會議邀請

此範例示範如何使用 Respond (OlMeetingResponse, Object, Object) 方法來自動接受會議邀請。

範例

注意事項

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

MeetingItem 物件代表將 AppointmentItem 物件代表的約會新增至收件者行事曆的要求。 若要回應會議邀請,請使用 GetAssociatedAppointment (Boolean) 方法來取得與會議邀請相關聯的 AppointmentItem 。 然後使用 AppointmentItemRespond (OlMeetingResponse、 Object、 Object) 方法,通知會議召集人是否已接受、拒絕或暫訂新增至收件者的行事歷。 Respond 方法接受三個參數。

Response 參數會指出回應是接受、拒絕還是暫訂。 fNoUI 和 fAdditionalTextDialog 參數是 bool 值,可判斷是否要傳送回應,以及使用者是否可以分別編輯回應。 在下列程式代碼範例中,AutoAcceptMeetingRequests 會列舉每個 MeetingItem 物件,以取得相關聯的 AppointmentItem。 AutoAcceptMeetingRequests 接著會使用 Respond 方法, 並將 fNoUI 參數設定為 true ,以指出會自動傳送回應以接受會議邀請。

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 AutoAcceptMeetingRequests()
{
    Outlook.MeetingItem mtgResponse;
    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(true);
        if (appt != null)
        {
            mtgResponse = appt.Respond(
                Outlook.OlMeetingResponse.olMeetingAccepted,
                true, Type.Missing);
            mtgResponse.Send();
        }
    }
}

另請參閱