Identify one appointment in recurring meetings

  • Thread starter Thread starter David
  • Start date Start date
D

David

Help, Help,
I am resubmitting this under a different subject. I have not found this anywhere and I can not resolve this.
There must be a way!
Even partial answer or guess will be excellent as i exhausted all other alternatives.

MVPs please help.

thanks in advance!
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
 
1. See AppointmentItem.GetRecurrencePattern.GetOccurence
2. See AppointmentItem.Respond

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

Help, Help,
I am resubmitting this under a different subject. I have not found this
anywhere and I can not resolve this.
There must be a way!
Even partial answer or guess will be excellent as i exhausted all other
alternatives.

MVPs please help.

thanks in advance!
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
 
Dmitry,
thanks for taking the time and looking into this. but
As you can see from the code below I am already using GetOccurence. But you need to specify the date you want and that is exactly the problem. How do I get the date/time user selected if this appointement is a recurring one?

Also, your answer to #2 is just stating what i have beeen doing. But i can live with my workaround on #2

thanks again

David


Dmitry Streblechenko (MVP) said:
1. See AppointmentItem.GetRecurrencePattern.GetOccurence
2. See AppointmentItem.Respond

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

Help, Help,
I am resubmitting this under a different subject. I have not found this
anywhere and I can not resolve this.
There must be a way!
Even partial answer or guess will be excellent as i exhausted all other
alternatives.

MVPs please help.

thanks in advance!
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
 
You will need to use the various recurrence properties
(RecurrencePattern.RecurrenceType, RecurrencePattern.Exception, etc) to
figure out the dates of the occurences. Unfortunately there is no way to
access recurrences by an index rather than a date.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


David said:
Dmitry,
thanks for taking the time and looking into this. but
As you can see from the code below I am already using GetOccurence. But
you need to specify the date you want and that is exactly the problem. How
do I get the date/time user selected if this appointement is a recurring
one?
Also, your answer to #2 is just stating what i have beeen doing. But i can live with my workaround on #2

thanks again

David


Dmitry Streblechenko (MVP) said:
1. See AppointmentItem.GetRecurrencePattern.GetOccurence
2. See AppointmentItem.Respond

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

Help, Help,
I am resubmitting this under a different subject. I have not found this
anywhere and I can not resolve this.
There must be a way!
Even partial answer or guess will be excellent as i exhausted all other
alternatives.

MVPs please help.

thanks in advance!
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
 
Dmitry,
Either I dont understand what you are saying or i am not clear enough.
Let me put an example:
I create a DAILY recurring meeting with 4 instances: Sunday to Wednesday

The user selected Monday and hit my macro. i want to be able to know that the user selected Monday.

Thanks
David

Dmitry Streblechenko (MVP) said:
You will need to use the various recurrence properties
(RecurrencePattern.RecurrenceType, RecurrencePattern.Exception, etc) to
figure out the dates of the occurences. Unfortunately there is no way to
access recurrences by an index rather than a date.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


David said:
Dmitry,
thanks for taking the time and looking into this. but
As you can see from the code below I am already using GetOccurence. But
you need to specify the date you want and that is exactly the problem. How
do I get the date/time user selected if this appointement is a recurring
one?
Also, your answer to #2 is just stating what i have beeen doing. But i can live with my workaround on #2

thanks again

David


Dmitry Streblechenko (MVP) said:
1. See AppointmentItem.GetRecurrencePattern.GetOccurence
2. See AppointmentItem.Respond

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

Help, Help,
I am resubmitting this under a different subject. I have not found this
anywhere and I can not resolve this.
There must be a way!
Even partial answer or guess will be excellent as i exhausted all other
alternatives.

MVPs please help.

thanks in advance!
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
 
Do you mean for the appointment item you get back the from
Explorer.Selection collection? I don't think you can do that.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


David said:
Dmitry,
Either I dont understand what you are saying or i am not clear enough.
Let me put an example:
I create a DAILY recurring meeting with 4 instances: Sunday to Wednesday

The user selected Monday and hit my macro. i want to be able to know
that the user selected Monday.
Thanks
David

Dmitry Streblechenko (MVP) said:
You will need to use the various recurrence properties
(RecurrencePattern.RecurrenceType, RecurrencePattern.Exception, etc) to
figure out the dates of the occurences. Unfortunately there is no way to
access recurrences by an index rather than a date.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


David said:
Dmitry,
thanks for taking the time and looking into this. but
As you can see from the code below I am already using GetOccurence.
But
you need to specify the date you want and that is exactly the problem. How
do I get the date/time user selected if this appointement is a recurring
one?
Also, your answer to #2 is just stating what i have beeen doing. But i
can
live with my workaround on #2
thanks again

David


:

1. See AppointmentItem.GetRecurrencePattern.GetOccurence
2. See AppointmentItem.Respond

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

Help, Help,
I am resubmitting this under a different subject. I have not found this
anywhere and I can not resolve this.
There must be a way!
Even partial answer or guess will be excellent as i exhausted all other
alternatives.

MVPs please help.

thanks in advance!
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
 
Back
Top