Responding to a Meeting Request (CDOEX)
Topic Last Modified: 2006-07-09
When you receive a meeting request in your inbox, you can accept it, accept it tentatively, reject it, or delete it. You typically save the meeting to your calendar folder after accepting the response.
Meeting requests are calendar messages that are identified by the ICalendarPart.CalendarMethod value REQUEST.
Note
CDOEX and ExOLEDB versions included in Exchange Server 2007 and Exchange Server 2003 Service Pack 2 handle meetings differently than previous versions of Exchange Server. A new Entry ID value is assigned to an item when it is accepted, tentatively accepted, or declined. The new Entry ID value is assigned regardless of where the item is stored when the action is taken.
The Collaboration Data Objects (CDO) Appointment object provides three methods for responding to meeting requests: Accept, AcceptTentative, and Decline. Each method returns a CalendarMessage object that is addressed to the meeting requester. Each method also updates the status of the meeting in memory so that if you save the meeting to your calendar, the status corresponds to the response you sent. You can also modify the message before sending it.
Note
None of the response methods changes the meeting request message in the inbox. Typically, the program deletes the meeting request message after a response is sent.
To respond to a meeting request
- Open each meeting in the calendar message as shown in Processing a Calendar Message.
- Based on the programming logic or user input, call the appropriate response method: Accept, AcceptTentative, or Decline.
- Make any desired changes to the response message (optional).
- Call the ICalendarMessage.Message.Send method to send the response.
- Save the meeting to the calendar folder.
- When you have finished processing all meetings in a calendar message, delete the message from the inbox.
The following example checks the inbox of a specific user. It accepts any meeting request with the word "lunch" in the subject line, and declines all other meetings. Then it deletes the calendar message from the inbox.
Example
Visual Basic
Note
The following example uses a file URL with the Exchange OLE DB (ExOLEDB) provider. The ExOLEDB provider also supports The HTTP: URL Scheme. Using The HTTP: URL Scheme allows both client and server applications to use a single URL scheme.
' Reference to Microsoft ActiveX Data Objects 2.5 Library
' Reference to Microsoft CDO for Exchange 2000 Library
Dim InboxURL As String
Dim CalendarURL As String
Dim itemURL As String
Dim Rs As New ADODB.Recordset
Dim Rec As New ADODB.Record
Dim iCalMsg As New CalendarMessage
Dim iCalMsg2 As CalendarMessage
Dim iCalPart As ICalendarPart
Dim iAppt As Appointment
Dim Index As Integer
Dim ContentClass As String
Dim Config As New Configuration
InboxURL = "file://./backofficestorage/" & DomainName & "/MBX/" & Username & "/inbox/"
CalendarURL = "file://./backofficestorage/" & DomainName & "/MBX/" & Username & "/calendar/"
'Set the configuration fields for the appointment objects
Config.Fields(cdoSendEmailAddress) = Username & "@" & DomainName
Config.Fields.Update
'Open the recordset for the calendar messages in the inbox folder
Rec.Open InboxURL
Set Rs.ActiveConnection = Rec.ActiveConnection
Rs.Source = "SELECT ""DAV:href"",""DAV:contentclass"" " & _
"FROM scope('shallow traversal of """ & InboxURL & """')" & _
"WHERE (""DAV:contentclass"" = 'urn:content-classes:calendarmessage')"
Rs.Open
'Enumerate the recordset and process each calendar message
Rs.MoveFirst
Do Until Rs.EOF
'Open the calendar message
itemURL = Rs.Fields(CdoDAV.cdoHref).Value
iCalMsg.DataSource.Open itemURL, , adModeReadWrite
iCalMsg.Configuration = Config
'Get each calendar part
For Index = 1 To iCalMsg.CalendarParts.Count
Set iCalPart = iCalMsg.CalendarParts(Index)
Set iAppt = iCalPart.GetUpdatedItem(CalendarURL)
Select Case iCalPart.CalendarMethod
Case "REQUEST"
'Accept any meeting with "lunch" in the subject text
If InStr(1, iAppt.Subject, "lunch", 1) Then
Set iCalMsg2 = iAppt.Accept
Else
Set iCalMsg2 = iAppt.Decline
End If
'Save the meeting
iAppt.DataSource.SaveToContainer CalendarURL
'Send the response
iCalMsg2.Message.Send
Case Else
'See the other examples in this section
End Select
Next Index
'Delete the calendar message
Rs.Delete
Rs.MoveNext
Loop