I am working with automating Outlook tasks and appts. I can add them and update them fine, but am having trouble deleting one. The problem seems to be that the Task object I get back from a Find does not provide the same Delete interface as the one I get back from an Add, even though I realize that it does/should. See below. I get the same results in both VFP8 and VFP7.
If I do this, it works (but not really what I need to do):
oo = CREATEOBJECT( 'Outlook.Application' )
ons = oo.GetNamespace('MAPI')
ofl = ons.GetDefaultFolder( 13 )
ot = ofl.Items.Add()
ot.DueDate=DATE()
ot.startdate=DATE()
ot.ReminderSet = .F.
ot.Subject = 'Test Task to Delete'
ot.Save
ot.Delete
After that, I see the new task in the Deleted items folder, so ot.Delete worked as expected here.
Following is more like what I need to do though -- find a task and then delete it. I do it based on a key value stored in a user-defined property in the real app, but I'm using the subject here as an easy test. I get back an object in ot after the find and Intellisense pops up the list with Delete in there. It shows no parameters, but then when I execute it I get a 'Paramater is not optional' error message.
oo = CREATEOBJECT( 'Outlook.Application' )
ons = oo.GetNamespace('MAPI')
ofl = ons.GetDefaultFolder( 13 )
ot = ofl.Items.Add()
ot.DueDate=DATE()
ot.startdate=DATE()
ot.ReminderSet = .F.
ot.Subject = 'Test Task to Delete'
ot.Save
RELEASE ot
ot = ofl.Items.Find( '[Subject]='Test Task to Delete'' )
ot.Delete
That gets the 'OLE error code 0x8002000f: Parameter not optional' error message.
If I change it to ot.Delete(), same problem. Any ideas at all?
Thanks.
Kelly