Reject/decline one appointment on a recurring meeting

D

David

Hello team,

I am trying to write a VBA routine for outlook2003 that will allow me to select multiple calendar items and reject/decline the appointments adding the same text to explain why i reject them (like going on vacation, trip etc).

Issue#1: how to handle the recurring meeting in which i want to reject one instance of them.
Issue#2: how to automate the creation of text that will go along with the decline message

Here is my initial attempt. Notice my workaround to issue#2. i am generating a new message rather than creating text to the decline message

thanks a lot.
David

---------------

Public Sub RejectInvites()

Dim myOlApp, myNameSpace As Object
Dim MyItem, Sel, DestinationFolder
Dim Appointment As AppointmentItem
Dim MyPattern As RecurrencePattern
Dim ThisAppointmentInstance As AppointmentItem
Dim MyException As Exceptions
Dim MyStr As String
Dim I, J, MyCount, response As Integer

MyStr = InputBox("Please enter the text to be used as the reason for cancellation", "Enter text")
If MyStr = "" Then Exit Sub


Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set Sel = Application.ActiveExplorer.Selection

For I = 1 To Sel.Count
If Sel.Item(I).Class = olAppointment Then
Set Appointment = Sel.Item(I)
' workaround for issue#2
Set MyItem = myOlApp.CreateItem(olMailItem)
MyItem.BodyFormat = olFormatPlain
MyItem.Subject = "Unable to attend this meeting [" & Appointment.Subject & "]"
MyItem.To = Appointment.Organizer
MyItem.Body = MyStr & vbCrLf & vbCrLf
MyItem.Body = MyItem.Body & "The invite was for: " & Appointment.Start & vbCrLf & vbCrLf ' ****** Issue#1 appointment.start is not the selected one
MyItem.Body = MyItem.Body & Appointment.Body
MyItem.Send


If Appointment.RecurrenceState = olApptNotRecurring Then
Appointment.Respond olMeetingDeclined, False, False 'True ', True ' no dialog
Else

Set MyPattern = Appointment.GetRecurrencePattern
Set ThisAppointmentInstance = MyPattern.GetOccurrence(Sel.Item(I).Start) ' ***** this is wrong. Help here is needed. Issue#1
ThisAppointmentInstance.Respond olMeetingDeclined, False, False

End If

End If

Next

Set myOlApp = Nothing

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top