Private WithEvents olkInbox As Outlook.Items
Private Sub Application_Quit()
Set olkInbox = Nothing
End Sub
Private Sub Application_Startup()
Set olkInbox = Session.GetDefaultFolder(olFolderInbox).Items
End Sub
Private Sub olkInbox_ItemAdd(ByVal Item As Object)
Dim olkMeeting As Outlook.MeetingItem, _
olkAppt As Outlook.AppointmentItem
If Item.Class = olMeetingRequest Then
Set olkAppt = Item.GetAssociatedAppointment(False)
'Change the subject text on the next line'
If Item.Subject = "Testing" Then
Set olkMeeting = olkAppt.Respond(olMeetingDeclined, True)
olkMeeting.Send
End If
End If
End Sub
|