Delete late bound Outlook AppointmentItem fails
Posted on 2004-03-22
I'm trying to delete an Outlook AppointmentItem for which I have the EntryID. Using late binding to avoid referencing a specific verison of Outlook.
Thefollowing code fails on myappt.delete with a 287 (Application defined or object defined error.):
Dim myAppt As Object 'AppointmentItem 'object
Dim myNS As Object 'NameSpace 'object
Dim myAppts As Object 'Items 'object
success = manageOutlookRef 'get a reference to Outlook
Set myNS = myOlApp.GetNamespace("MAPI")
Set myAppts = myNS.GetDefaultFolder(9).items '9=olFolderCalendar
Set myAppt = myNS.getItemFromID(OutID)
If Not myAppt Is Nothing Then
'delete it and stop
myAppt.Delete <<<<<<<FAILS HERE
UpdateStatusBar " Outlook Appointment deleted."
I can get the typeName, Class, subject of myAppt, but not its start, end or Outlookversion (?) What's wrong with my code? or whats a surefire way of doing this from VB6 (late bound)?