Microsoft KB Archive/232626

= PRB: CDO: MAPI_E_NO_SUPPORT When Using CDO (1.x) ClearRecurrencePattern =

Article ID: 232626

Article Last Modified on 3/4/2004

-

APPLIES TO


 * Microsoft Collaboration Data Objects 1.2
 * Microsoft Collaboration Data Objects 1.21

-



This article was previously published under Q232626



SYMPTOMS
When trying to delete a recurring appointment, calling the CDO (1.2, 1.21) ClearRecurrencePattern method of the AppointmentItem produces the following error:

MAPI_E_NO_SUPPORT



CAUSE
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.



RESOLUTION
Use the following steps to correctly delete the recurrence pattern of the Appointment item:  Get a reference to the appointment item that has recurring pattern associated with it.  Get the master occurrence of the appointment by using the following: Set MasterAppt = objAppointmentItem.GetRecurrencePattern.Parent  Clear the recurrence pattern using the ClearRecurrencePattern method. Update the Master appointment using the Update method.

Below is a code sample that creates a recurring appointment and then correctly deletes the recurrence pattern and the master appointment:

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.

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" 'Replace 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

<div class="status_section">

STATUS
This behavior is by design.

<div class="moreinformation_section">

MORE INFORMATION
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.

<div class="references_section">