/// <summary> /// Get events matching the subject. /// </summary> /// <returns> /// Array of relevant events or empty array. /// </returns> private ArrayList GetEventItems() { // Use a Jet Query to filter the details we need initially between the two specified dates string dateFilter = $"[Start] >= '{StartDate:g}' and [End] <= '{EndDate:g}'"; _Items calendarItems = s_mapiFolder.Items.Restrict(dateFilter); calendarItems.Sort("[Start]", Type.Missing); calendarItems.IncludeRecurrences = true; // Must use 'like' comparison for Find/FindNext string subjectFilter = !String.IsNullOrEmpty(Subject) ? $"@SQL=\"urn:schemas:httpmail:subject\" like '%{Subject.Replace("'", "''")}%'" : "@SQL=\"urn:schemas:httpmail:subject\" <> '!@#'"; // Use Find and FindNext methods to get all the items ArrayList resultArray = new ArrayList(); AppointmentItem eventItem = calendarItems.Find(subjectFilter) as AppointmentItem; while (eventItem != null) { resultArray.Add(eventItem); // Find the next event eventItem = calendarItems.FindNext() as AppointmentItem; } return(resultArray); }
public static IEnumerable <T> ToEnumerable <T>(this _Items items) { while (true) { var a = items.FindNext(); if (a == null) { break; } yield return((T)a); } }
protected override List <_AppointmentItem> PrepareItemsForExchange(_Items items) { List <_AppointmentItem> result = new List <_AppointmentItem>(); if (items == null) { return(result); } string filter = FormatInterval(Interval); _AppointmentItem olApt = items.Find(filter) as _AppointmentItem; while (olApt != null) { result.Add(olApt); olApt = items.FindNext() as _AppointmentItem; } return(result); }