Created
June 9, 2017 15:30
-
-
Save davecra/9e32d2a47273d1aac085b75b9df9545a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// EXTENSION METHOD | |
/// Get all the appointments between the given date times | |
/// </summary> | |
/// <param name="PobjItems"></param> | |
/// <param name="PobjStart"></param> | |
/// <param name="PobjEnd"></param> | |
/// <returns></returns> | |
public static List<Outlook.AppointmentItem> FindAppointments(this Outlook.Items PobjItems, | |
DateTime PobjStart, | |
DateTime PobjEnd) | |
{ | |
try | |
{ | |
List<Outlook.AppointmentItem> LobjReturn = new List<Outlook.AppointmentItem>(); | |
string LstrCriteria = "[Start] >= \"" + PobjStart.ToString("g") + "\" AND [End] <= \"" + PobjEnd.ToString("g") + "\""; | |
// FIX: we must use [Start] in the Sort to get the right recurrence | |
// for todays date... | |
PobjItems.Sort("[Start]"); | |
PobjItems.IncludeRecurrences = true; | |
PobjItems = PobjItems.Restrict(LstrCriteria); | |
object LobjItem = PobjItems.GetFirst(); | |
// chcek the appointments or meetings against the | |
// the rules and set Skype status | |
Outlook.AppointmentItem LobjAppt = null; | |
do | |
{ | |
if (LobjItem is Outlook.MeetingItem) | |
{ | |
LobjAppt = ((Outlook.MeetingItem)LobjItem).GetAssociatedAppointment(false); | |
} | |
else | |
{ | |
LobjAppt = (Outlook.AppointmentItem)LobjItem; | |
Debug.Print(" >>>>>>>>>>> " + LobjAppt.Subject); | |
} | |
// as long as we are not null | |
if (LobjItem != null) | |
{ | |
LobjReturn.Add(LobjAppt); | |
LobjItem = PobjItems.GetNext(); | |
} | |
} | |
while (LobjItem != null); | |
// done | |
return LobjReturn; | |
} | |
catch (Exception PobjEx) | |
{ | |
PobjEx.Log(false); | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment