Export (0) Print
Expand All

How to: 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.

Programming Applications for Office Outlook 2007

The following code example is an excerpt from Programming Applications for Microsoft Office Outlook 2007, from Microsoft Press (ISBN 9780735622494, copyright Microsoft Press 2007, all rights reserved).

Buy this book

Sample chapters

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 Microsoft Visual Studio to test this code example, you must first add a reference to the Microsoft Outlook 14.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);
        }
    }
}

Other Resources

Community Additions

ADD
Show:
© 2014 Microsoft