none
Get employees' work day hours RRS feed

  • Question

  • In outlook you can specify your regular work hours like 9am to 5pm. I was wondering if there is a way to retrieve this data for every employee in a mailing list. I got as far as getting everyone's freebusy time:

    if (contactGroup != null && contactGroup.Subject != null && contactGroup.Subject != "")
    {
        contactGroup.Load();
    
        foreach (GroupMember member in contactGroup.Members)
        {
            NameResolutionCollection nameResolutions = service.ResolveName(
                    member.AddressInformation.Name,
                    ResolveNameSearchLocation.DirectoryOnly,
                    true);
    
    
            foreach (NameResolution nameResolution in nameResolutions)
            {
    
                // now get all members of this mailing list
    
                ExpandGroupResults groupResults = service.ExpandGroup(nameResolution.Mailbox.Address);
                string[] mailboxes = new string[groupResults.Count];
                string[] names = new string[groupResults.Count];
                AttendeeInfo[] user_list = new AttendeeInfo[groupResults.Count];
                int counter = 0;
    
                foreach (Microsoft.Exchange.WebServices.Data.EmailAddress email_addy in groupResults.Members)
                {
                    AttendeeInfo attendee_info = new AttendeeInfo(email_addy.Address);
                    mailboxes[counter] = email_addy.Address;
                    names[counter] = email_addy.Name.ToString();
                    user_list[counter] = attendee_info;
                    counter++;
                }
    
    
    
                // grab everyone's schedules and loop through it doing some processing as I go
    
                GetUserAvailabilityResults availabilities = service.GetUserAvailability(user_list.AsEnumerable<AttendeeInfo>(), new TimeWindow(start, end), AvailabilityData.FreeBusy);
    
                for (int i = 0; i < availabilities.AttendeesAvailability.Count; i++)
                {
                }
            }
        }
    }


    So is there a way to get people's work day hours from this? I'm trying to avoid impersonation since I don't have permissions to do that and I don't think I could ever get those permissions. Thanks.

     



    • Edited by Toxxmaster Friday, October 21, 2011 8:07 PM
    Friday, October 21, 2011 8:01 PM

Answers

  • Hi,

    assuming your are working with Exchange 2010, you can use EWS here:

    var workHoursConfiguration = UserConfiguration.Bind(service, "WorkHours",
    WellKnownFolderName.Calendar, UserConfigurationProperties.All);
    var workHours =
    XDocument.Parse(Encoding.UTF8.GetString(workHoursConfiguration.XmlData));

    The configuration you are looking for is stored in a hidden item in the calendar of a users default calendar; so you'll need at least read permission on everyone's calendar folder.

    Kind regards,
    Henning

    If you get your question answered, please come back and mark the reply as an answer.
    If you are helped by an answer to someone else's question, please mark it as helpful.

    • Marked as answer by Toxxmaster Wednesday, October 26, 2011 5:03 PM
    Friday, October 21, 2011 10:18 PM

All replies

  • Hi,

    assuming your are working with Exchange 2010, you can use EWS here:

    var workHoursConfiguration = UserConfiguration.Bind(service, "WorkHours",
    WellKnownFolderName.Calendar, UserConfigurationProperties.All);
    var workHours =
    XDocument.Parse(Encoding.UTF8.GetString(workHoursConfiguration.XmlData));

    The configuration you are looking for is stored in a hidden item in the calendar of a users default calendar; so you'll need at least read permission on everyone's calendar folder.

    Kind regards,
    Henning

    If you get your question answered, please come back and mark the reply as an answer.
    If you are helped by an answer to someone else's question, please mark it as helpful.

    • Marked as answer by Toxxmaster Wednesday, October 26, 2011 5:03 PM
    Friday, October 21, 2011 10:18 PM
  • This is good info. Thanks for the reply. Do you know if there is a list somewhere that shows all possible configuration names other than "WorkHours"? Maybe appointments too?

    I'm trying to get everyone's public calendar info without supplying my login credentials when connecting to ews server.

    Wednesday, October 26, 2011 5:08 PM