I've got the following code:
var startProp = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.Meeting, "DTSTART", MapiPropertyType.String);
var endProp = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.Meeting, "DTEND", MapiPropertyType.String);
var cond1 = new SearchFilter.IsEqualTo(startProp, StartDate);
var cond2 = new SearchFilter.IsEqualTo(endProp, EndDate);
var filter = new SearchFilter.SearchFilterCollection(LogicalOperator.And, cond1, cond2);
var items = svc.FindItems(WellKnownFolderName.Calendar, filter, view);
I am trying to run this query on an exchange room mailbox. (This is not apparent in the code above however). It may have reservation with the exact start/end time. Hence if there is one reservation matching that criteria, I should get at least one item.
The background to this: think of a meeting room and people are trying to block it for a meeting. On exchange, this is just another mailbox, similar to a user mailbox. So on successful reservation, this mailbox gets an email with the calendar details (iCalendar format (*.ics
).
I am stuck on two different counts...
items
don't return anything in the code above. The TotalCount
is zero. Maybe I am doing something wrong with the api. I am unable to figure this.
I am actually confused with what I am trying to query. I don't understand exchange's resolution in this matter. This is described further below.
So you've email items in a room mailbox. Each email has the calendar embedded with it usually with some base64 encoding. The calendar has a specific schema - we are only interested in the data you find in between VEVENTS (i.e BEGIN:VEVENT and END:VEVENT). The issue here is that there can be multiple VEVENTS sometimes. So how does exchange really do it? Does it run through all the VEVENTS, match the criteria; if it matches successfully, does it return that "email" (with the calendar attached/embedded)? Or it is some other mechanism?
Hence I am unsure of the semantic I've written in the code above. So please advise on this.
FreeBusy uses EWS (Exchange Web Services) protocol, not ActiveSync. EWS is typically deployed together with OWA (Outlook Web App). If your company offers OWA to employees, then you can use FreeBusy, and you can sign up on your own without assistance from your IT department.
This option can be useful when you don't have your Outlook app at hand. Still, in companies using Exchange Online, OWA and EWS can go hand-in-hand. For example, your employees can use OWA to check their emails, access their calendars, revise their To-Do lists, all without being on their device.
Found the answer to the first part:
static void Find(DateTime Start, DateTime End, ExchangeService svc)
{
var filter1 = new SearchFilter.IsGreaterThanOrEqualTo(MeetingRequestSchema.Start, Start);
var filter2 = new SearchFilter.IsLessThanOrEqualTo(MeetingRequestSchema.End, End);
var filter = new SearchFilter.SearchFilterCollection(LogicalOperator.And, filter1, filter2);
var vw = new ItemView(99);
var items = svc.FindItems(WellKnownFolderName.Calendar, filter, vw);
Console.WriteLine("Count: {0}", items.TotalCount);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With