Created
July 3, 2017 15:13
-
-
Save davecra/ebeaa59cf95afdc0a3efddb027d23df8 to your computer and use it in GitHub Desktop.
This does not work
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") + "\""; | |
// we want to find the oldest first. This way we do | |
// not get stuck on all day appointments that are conflicting | |
// with the current value. | |
PobjItems.Sort("[End]"); | |
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; | |
} | |
// 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