开发者

Outlook does not return appointment recurrences

I'm playing around with VSTO for Outlook 2007.

When accessing appointments in calendar, I'd like to see all recurrences - not only the series-main item.

My code is as following

var calendarFolder = Globals.TestAddin.Application.GetNamespace("MAPI").GetDefaultFolder(OlDefaultFolders.olFolderCalendar);
var outlookCalendarItems = calendarFolder.Items;
outlookCalendarItems.IncludeRecurrences = includeRecurring;

var appointmentItems = outlookCalendarItem开发者_如何转开发s.Cast<AppointmentItem>();
foreach ( var appointmentItem in appointmentItems )
{
  var item = appointmentItem;
  this.LogBox.AppendText(item.Subject);
}

It shows all normal items, all series-master items but no calculated series appointments.

Example: it shows my mothers birthday in october 1949 as an recurring item, but none of her following birthdays in 1950, 1951... etc.

What am I doing wrong?

Thanks for ideas!

Sascha


Adding one single line did it:

outlookCalendarItems.Sort("[Start]");


When including recurrences without a 'Find' between dates, this code has potential to become an eternal loop.

This is because it will create an 'appointmentItem' for each occurrence it can find. If there are recurring calendar items which have no recurrence end date set, this loop will continue to create 'appointmentItem's for every occurrence (forever).

To get around this, you need to limit the results you find, see below how to limit results.:

http://msdn.microsoft.com/en-us/library/office/dd469461(v=office.12).aspx

Set currentAppointment = myAppointments.Find("[Start] >= """ & _
        tdystart & """ and [Start] <= """ & tdyend & """")
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜