This Visual Basic for Applications example uses the Find method to locate a MeetingItem in the user's Inbox. If there are no meeting items, the user is informed. If a meeting item is located, the GetAssociatedAppointment method is called to get the AppointmentItem and the Respond method allows acceptance.
Set myOlApp = CreateObject("Outlook.Application")
Set myNamespace = myOlApp.GetNamespace("MAPI")
Set myFolder = myNamespace.GetDefaultFolder(olFolderInbox)
Set myMtgReq = myFolder.Items.Find("[MessageClass] = 'IPM.Schedule.Meeting.Request'")
If TypeName(myMtgReq) <> "Nothing" Then
Set myAppt = myMtgReq.GetAssociatedAppointment(True)
myAppt.Respond olResponseAccepted, False, True
Else
MsgBox "You have no meeting requests."
End If
If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.
Set myNamespace = Application.GetNamespace("MAPI")
Set myFolder = myNamespace.GetDefaultFolder(6)
Set myMtgReq = myFolder.Items.Find("[MessageClass] = 'IPM.Schedule.Meeting.Request'")
If TypeName(myMtgReq) <> "Nothing" Then
Set myAppt = myMtgReq.GetAssociatedAppointment(True)
myAppt.Respond olResponseAccepted, False, True
Else
MsgBox "You have no meeting requests."
End If