Howto: Accept meeting requests with VB6 and CDO 1.21

Here is a sample to accept all meeting requests using CDO 1.21.

' The code below will accept all meeting requests in the users inbox.
Private Sub cmdAcceptRecurringMeeting_Click()
   Dim objSession As mapi.Session
    Dim ObjMessage As mapi.Message
    Dim oMessages As mapi.Messages
    Dim oAppointment As mapi.AppointmentItem
    Dim oFolder As mapi.Folder
    Dim objOrig As AppointmentItem
    Dim objRecPatt As RecurrencePattern
    Dim oRecipients As mapi.Recipients
    Dim oRecipient As mapi.Recipient
    Dim oMeetingReq As mapi.MeetingItem
    Dim oMeetingRes As mapi.MeetingItem

    'Create the Session Object.
    Set objSession = New mapi.Session
    'Logon using the session object.
    'objSession.Logon "", "", False, True, 0, True, "myserver" & vbLf & "mymailbox"
    Set oFolder = objSession.GetDefaultFolder(CdoDefaultFolderInbox)
    Set oMessages = oFolder.Messages
    Set oMeetingReq = oMessages.GetFirst
    Do While Not oMeetingReq Is Nothing
        Dim sType As String
        Dim lClass As Long
        sType = oMeetingReq.Type   '"IPM.Schedule.Meeting.Request"
        lClass = oMeetingReq.Class
        If (sType = "IPM.Schedule.Meeting.Request" And lClass = CdoMeetingItem) Then
            Set oMeetingRes = oMeetingReq.Respond(CdoResponseAccepted)
            oMeetingRes.Send True
            Set oMeetingRes = Nothing
        End If
        Set oMeetingReq = oMessages.GetNext
End Sub

Comments (0)

Skip to main content