共用方式為


提示用戶回應會議邀請

此範例示範如何提示用戶回應會議邀請,以及讓使用者在傳送回應之前編輯回應。

範例

注意事項

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

AppointmentItem 物件的 Respond 方法可用來通知會議召集人是否已接受、拒絕或暫訂加入至收件者的行事曆。 藉由使用 Respond 方法,您可以指出是否要自動傳送通知,或是否要允許使用者在傳送回應之前編輯回應。 Respond 方法接受三個參數。 Response 參數會指出回應是接受、拒絕還是暫訂。 fNoUIfAdditionalTextDialog 參數是 bool 值,指出是否要將回應傳送給召集人,以及使用者是否可以分別在傳送回應之前編輯回應本文。

在下列程式代碼範例中,PromptUserMeetingRequest 會列舉 MeetingItem 物件以取得相關聯的 AppointmentItem 對象,然後呼叫 Respond 方法, 並將 fNoUI 參數設定為 false並將 fAdditionalTextDialog 參數設定為 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 PromptUserMeetingRequest()
{
    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,
                false, true);
        }
    }
}

另請參閱