In my Outlook Add-in I want to be able to filter my default calendar for appointments that have the following criteria:
- all-day events = true
- reminders set = true
I have figured out how to use DASL to search for those items, but how do I get the calendar view to show those filtered results?
Here is the code I have so far:
internal class MyAppointment : Appointment
{
[OutlookItemProperty("urn:schemas:calendar:dtstart")]
public DateTime Start { get { return Item.Start; } }
[OutlookItemProperty("urn:schemas:calendar:dtend")]
public DateTime End { get { return Item.End; } }
public bool ReminderSet { get { return Item.ReminderSet; } }
public bool AllDayEvent { get { return Item.AllDayEvent; } }
}
void btnFix_Click(Microsoft.Office.Core.CommandBarButton Ctrl, ref bool CancelDefault)
{
Outlook.Folder folder = (Outlook.Folder)Globals.ThisAddIn.Application.Session.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderCalendar);
var appts = from item in folder.Items.AsQueryable<MyAppointment>()
where item.Start >= DateTime.Now
&& item.End <= DateTime.Now.AddMonths(1)
&& item.ReminderSet
&& item.AllDayEvent
select item.Item;
// bind to Calendar view???
}
I now have a collection of Appointments. How do I get the calendar to show them?