The MeetingItem object is unlike other Outlook objects in that you cannot explicitly create it. This object is created when you change the MeetingStatus property of an AppointmentItem object and send the object to other users. The objects that these users receive are MeetingItem objects. The following sections describes the common scenarios for using the MeetingItem object in your applications.
Outlook provides you with the capabilities to create meeting requests when you set the MeetingStatus property of an appointment to olMeeting (1) and send the meeting request to some attendees. You can specify whether the attendees are required, optional, or resources. Resources are added as BCC recipients to the meeting. The following code shows you how to create and send a meeting request programmatically from Outlook:
Sub CommandButton1_Click set oNS = Application.GetNameSpace("MAPI") set oCalendar = oNS.GetDefaultFolder(9) set oNewAppt = oCalendar.Items.Add oNewAppt.Subject = "Meet with John" oNewAppt.Location = "John's office" oNewAppt.Start = #10/1/98 3:00 PM# oNewAppt.End = #10/1/98 4:00 PM# oNewAppt.MeetingStatus = 1 set oRecips = oNewAppt.Recipients set oRequire = oRecips.Add("John") oRequire.Type = 1 oNewAppt.Display End Sub |
If your application is an Outlook application, typically you won't have to worry about creating code to respond to meeting requests because Outlook has this functionality built in. However, if you are automating Outlook from another application and you do not to want your users to log on to Outlook, you will need to give them the ability to respond to meeting requests. The built-in capabilities of the AppointmentItem object enables you to handle this functionality. You may be wondering how you get the AppointmentItem object when a user receives a MeetingItem object in their Inbox. Well, for the MeetingItem object, Outlook provides a GetAssociatedAppointment method that allows you to retrieve the associated appointment that is linked to the MeetingItem object. Note that you must pass either True or False as a required parameter to GetAssociatedAppointment. This parameter specifies whether to add the appointment to the user's default calendar. Then you can call the Respond method on the AppointmentItem object to respond to the meeting request.
The Respond method takes three parameters; two of these are optional:
For more details on these parameters, refer to the Olform.hlp file on the companion CD.
The following sample finds a MeetingItem in the Inbox and uses the Respond method to send back a response that prompts the user about whether to immediately send the item or edit it before sending:
Sub CommandButton1_Click set oNS = Application.GetNameSpace("MAPI") set oInbox= oNS.GetDefaultFolder(6) set oItems = oInbox.Items set oMtgReqs = oItems.Restrict( _ "[Message Class]=""IPM.Schedule.Meeting.Request""") set oMtgReq = oMtgReqs.GetFirst set oAppt = oMtgReq.GetAssociatedAppointment(True) msgbox "The meeting request is called " & oAppt.Subject oAppt.Respond 3, False, True End Sub |