D
D-Code-99
Hi,
I have a strange problem with Outlook automation of the calendar. I have
mail, tasks etc working perfectly. This is a VC6 app with the MFC wrappers
around the Outlook 2k automation interface.
I'm trying to retrieve a list of all calendar items in the next X days,
including recurrences. I have 2 problems.
Problem 1: Without recurrences, I can't get the details (eg: subject) of any
calendar items. Code sample:
MAPIFolder olCalendar = olNs.GetDefaultFolder(FolderType_olFolderCalendar);
olItems = olCalendar.GetItems();
_Items ol7DayItems = olItems.Restrict(_T("[Start] > '04/12/2005' and
[Start] < '11/12/2005'"));
_AppointmentItem olCalendarItem = ol7DayItems.GetFirst();
for(int iCalendarItemCount = 0; iCalendarItemCount <=
ol7DayItems.GetCount(); iCalendarItemCount++)
{
olCalendarItem = ol7DayItems.GetNext();
CString cstrSubj = olCalendarItem.GetSubject();
}
In this code, ol7DayItems.GetCount() is correct but cstrSubj is always blank.
Problem 2: With recurrence enabled, GetCount() returns a crazy number.
Sample code:
olItems = olCalendar.GetItems();
iCount = olItems.GetCount();
olItems.SetIncludeRecurrences(TRUE);
olItems.Sort(_T("[Start]"), g_covFalse);
iCount = olItems.GetCount();
The first call to GetCount() correctly returns the number of items. The
second call returns 2147483647. When retrieving the items, the first
recurring item is retrieved correctly (I can actually get the subject), but
the rest return blank as above. I also admit I don't understand why the
collection must be sorted by Start in ascending order, but that's the only
time recurrence appears to work.
All help appreciated, thanks!
I have a strange problem with Outlook automation of the calendar. I have
mail, tasks etc working perfectly. This is a VC6 app with the MFC wrappers
around the Outlook 2k automation interface.
I'm trying to retrieve a list of all calendar items in the next X days,
including recurrences. I have 2 problems.
Problem 1: Without recurrences, I can't get the details (eg: subject) of any
calendar items. Code sample:
MAPIFolder olCalendar = olNs.GetDefaultFolder(FolderType_olFolderCalendar);
olItems = olCalendar.GetItems();
_Items ol7DayItems = olItems.Restrict(_T("[Start] > '04/12/2005' and
[Start] < '11/12/2005'"));
_AppointmentItem olCalendarItem = ol7DayItems.GetFirst();
for(int iCalendarItemCount = 0; iCalendarItemCount <=
ol7DayItems.GetCount(); iCalendarItemCount++)
{
olCalendarItem = ol7DayItems.GetNext();
CString cstrSubj = olCalendarItem.GetSubject();
}
In this code, ol7DayItems.GetCount() is correct but cstrSubj is always blank.
Problem 2: With recurrence enabled, GetCount() returns a crazy number.
Sample code:
olItems = olCalendar.GetItems();
iCount = olItems.GetCount();
olItems.SetIncludeRecurrences(TRUE);
olItems.Sort(_T("[Start]"), g_covFalse);
iCount = olItems.GetCount();
The first call to GetCount() correctly returns the number of items. The
second call returns 2147483647. When retrieving the items, the first
recurring item is retrieved correctly (I can actually get the subject), but
the rest return blank as above. I also admit I don't understand why the
collection must be sorted by Start in ascending order, but that's the only
time recurrence appears to work.
All help appreciated, thanks!