RecurrencePattern.GetOccurrence() fails on patterns from recurringTasks

J

Jeff

I'm getting a

"Member not found. (Exception from HRESULT: 0x80020003
(DISP_E_MEMBERNOTFOUND))"

error when I try to get a particular occurrence of a recurring task.

The MSDN documentation implies that you can get an particular
occurrence of an appointment or task using the following technique
(expressed here is pseudocode):

Item recurringItem = NameSpace.GetItemFromId(entryId,storeId);
RecurrencePattern pattern = recurringItem.GetRecurrencePattern();
Item occurrence = pattern.GetOccurrence(date);

That approach works correctly w/ recurring appointments,
however, .GetOccurrence() fails when the item is a task.

I'm sure that there is a recurring task on 'date', b/c I can see the
task in Outlook. I'm aware of the fact that GetOccurrence() will throw
an exception if there is no occurrence on that date; that's not the
issue I'm having.

Thanks in advance.

jb
 
S

Sue Mosher [MVP]

Recurring tasks don't work the same way as appointments. There is no master
task with a RecurrencePattern that lists all the individual tasks in its
Recurrences and Exceptions collections. Instead, each task created by the
recurrence pattern is an independent item. Therefore, you should be able to
use MAPIFolder.Items.Find to search by the specific date and other
information you know about the task.
 
D

Dmitry Streblechenko

Actually on the low level, the recurrence info on tasks is almost exactly
the same as on appointments.
It is just OOM defines the return type of the
RecurrencePattern.GetOccurrence method (that object is shared by both
appointment and taks objects) as Outlook.AppointmentItem, which makes no
sense for tasks.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top