Prompt a user to respond to a meeting request

This example shows how to prompt the user for a response to a meeting request, and to enable the user to edit the response before sending it.

Example

Note

The following code example is an excerpt from Programming Applications for Microsoft Office Outlook 2007.

The Respond method of the AppointmentItem object is used to notify the meeting organizer whether the meeting has been accepted, declined, or tentatively added to the recipient’s calendar. By using the Respond method, you can indicate whether you want to send the notification automatically, or whether you want to allow the user to edit the response before sending it. The Respond method accepts three parameters. The Response parameter indicates whether the response is accept, decline, or tentative. The fNoUI and fAdditionalTextDialog parameters are bool values that indicate whether the response will be sent to the organizer, and whether the user can edit the body of the response before sending it, respectively.

In the following code example, PromptUserMeetingRequest enumerates through the MeetingItem objects to get the associated AppointmentItem objects, and then calls the Respond method with the fNoUI parameter set to false and the fAdditionalTextDialog parameter set to true. This allows the user to choose whether to send a response, and whether to edit the body of the response before sending it.

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

See also