How to get today's schedule for a particular user using EWS

What is the right way to get the calendar information for a single email address using EWS? I found ListAppointments() but that seems to get the entire directory. I would like to just find a single person with a datetime range to see what they have going on today.

Thanks,
Josh

Hi Josh,


Thank you for writing to Aspose Support team.

We have looked into it and couldn’t find any relevant method for listing appointments for a specific user. The ExchangeQueryBuilder could be of help to us in this regard, but it seems the search feature on From/To fields in this case is not working for some reason. Could you please share with us if you want to search by organizer or attendees?

Thank you for the quick response. The reason I want to do this is to show the schedule of an employee on our webpage. I’d like users to see their free/busy times for today so they can quickly see what that person is doing today without having to go to outlook and create a dummy appointment just to view their schedule. Does that make sense?

Hi Josh,


You can use the following sample code for this purpose. Please try it at your end and let us know your feedback.

Sample Code:

ExchangeQueryBuilder builder = new ExchangeQueryBuilder();

builder.InternalDate.On(DateTime.Today);

IEWSClient client = GetAsposeEWSClient1();

ExchangeMailboxInfo mi = client.GetMailboxInfo("user@domain.com");

Appointment[] appts = client.ListAppointments(mi.CalendarUri, builder.GetQuery());

Console.WriteLine(appts.Count());

foreach(Appointment app in appts)
{
Console.WriteLine(app.StartDate);

Console.WriteLine(app.EndDate);
}

This code does work for my own email address but it fails to read appointments of other people due to privileges. I don’t need to see the internals of the appointment, only that they are busy. The public meta data is all I need(and would have access to anyway).

Hi Josh,


You need to have access to another user’s mailbox for checking his/her calendar. There is no other way to get this information. Please let us know if we could be of any additional help to you in this regard.