PRB: CDO: MAPI_E_NO_SUPPORT When Using ClearRecurrencePattern

ID: Q232626


The information in this article applies to:


SYMPTOMS

When trying to delete a recurring appointment, calling the 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:

  1. Get a reference to the appointment item that has recurring pattern associated with it.


  2. Get the master occurrence of the appointment by using the following:
    
    Set MasterAppt = objAppointmentItem.GetRecurrencePattern.Parent 


  3. Clear the recurrence pattern using the ClearRecurrencePattern method.


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


STATUS

This behavior is by design.


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.


REFERENCES

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