PRB: CDO: MAPI_E_NO_SUPPORT When Using ClearRecurrencePatternID: Q232626
|
When trying to delete a recurring appointment, calling the ClearRecurrencePattern method of the AppointmentItem produces the following error:
MAPI_E_NO_SUPPORT
The RecurrencePattern object applies only to its parent appointment and cannot be used for any other AppointmentItem object. The recurrence pattern can be accessed from any appointment in the recurring series; that is, from an individual recurrence of the appointment as well as from the appointment that originated the recurring series. ClearRecurrencePattern cannot be called on an occurrence only on the recurring master or a single appointment.
Use the following steps to correctly delete the recurrence pattern of the Appointment item:
Set MasterAppt = objAppointmentItem.GetRecurrencePattern.Parent
Private Sub Form_Load()
Dim objSess As MAPI.Session
Dim folder As folder
Dim msgs As Messages
Dim ApptItem As AppointmentItem
Dim MasterAppt As AppointmentItem
Const CALID = &H80000003
' Create the Session and logon
Set objSess = CreateObject("MAPI.Session")
'Replace "Server" and "mailbox" in the line below to the appropriate
'names depending on what you are using to log on to.<BR/>
objSess.Logon "", "", False, True, 0, True, "Server" & vbLf & "Mailbox"
Set ApptItem = objSess.GetDefaultFolder(CdoDefaultFolderCalendar).Messages.Add
'Create Appointment item
ApptItem.StartTime = #4/7/1999 9:00:00 AM#
ApptItem.EndTime = #4/7/1999 4:00:00 PM#
ApptItem.AllDayEvent = False
ApptItem.ReminderSet = False
ApptItem.Location = "Location"
ApptItem.Text = "Comment"
ApptItem.Subject = "Event"<BR/>
'Replace <user> in the line below with a valid User who you want to send 'this appointment invitation.
ApptItem.Recipients.Add "<User>"
ApptItem.Recipients.Resolve
ApptItem.MeetingStatus = 1
'Set the recurrence pattern
Set rpt = ApptItem.GetRecurrencePattern
rpt.RecurrenceType = 0
rpt.Interval = 2
rpt.Occurrences = 2
ApptItem.Update True, True
ApptItem.Send
Set ApptItem = Nothing
'Delete Appointment item
Set msgs = objSess.GetDefaultFolder(0).Messages
For Each ApptItem In msgs
If ApptItem.Subject = "Event" Then
If ApptItem.IsRecurring Then
' You need do the following to make sure that you are getting the master
' occurrence of the appointment.
Set MasterAppt = ApptItem.GetRecurrencePattern.Parent 'Get the parent Appointment
MasterAppt.ClearRecurrencePattern
MasterAppt.Update
End If
MasterAppt.Delete 'Still need to delete the master appointment
Set MasterAppt = Nothing 'Set the master appointment to nothing
'Cleanup
Set ApptItem = Nothing
Exit For
End If
Next
End Sub
This behavior is by design.
The ClearRecurrencePattern method sets the IsRecurring property to False and dissociates this AppointmentItem object from any RecurrencePattern object it might have had assigned to it.
ClearRecurrencePattern calls Release on the RecurrencePattern object. This is normally the final Release because the RecurrencePattern object applies only to its parent appointment and cannot be used for any other AppointmentItem object. The RecurrencePattern object is removed from memory in response to its final Release.
The ClearRecurrencePattern method is valid only on a nonrecurring appointment or an appointment originating a recurring series. An attempt to call it on an individual recurrence in a series returns CdoE_NO_SUPPORT.
For more information about the "ClearRecurrencePattern" please refer to Microsoft Developer Network.
Additional query words: kbDSupport kbGrpMsg kbMsg kbCDO kbCDO120 kbCDO121 kbVb
Keywords : kbCDO kbCDO120 kbCDO121 kbMsg kbVC kbGrpMsg kbDSupport
Version : WINDOWS:1.2,1.21
Platform : WINDOWS
Issue type : kbprb
Last Reviewed: June 10, 1999