次の方法で共有


GetUserAvailabilityRequestType Class

The GetUserAvailabilityRequestType class represents an operation to get the availability information for a user.

Inheritance Hierarchy

System.Object
  ExchangeWebServices.BaseRequestType
    ExchangeWebServices.GetUserAvailabilityRequestType

Namespace:  ExchangeWebServices
Assembly:  EWS (in EWS.dll)

Syntax

'Declaration
<SerializableAttribute> _
Public Class GetUserAvailabilityRequestType _
    Inherits BaseRequestType
'Usage
Dim instance As GetUserAvailabilityRequestType
[SerializableAttribute]
public class GetUserAvailabilityRequestType : BaseRequestType

Remarks

The order in which mailboxes are added to the request represents the order in which mailbox information is received in the response.

Examples

The following code example shows you a GetUserAvailability query that includes the following elements:

  1. A time window for free/busy data that includes today and tomorrow.

  2. A request for detailed and merged free/busy information about the calendar events for each mailbox. This example shows a request for detailed information. However, the actual information that is returned can vary based on the caller's rights to view the calendar information for other mailboxes.

  3. A defined interval for which the merged free/busy data is to be returned; in this case, 30 minutes. This is ignored if merged free/busy data is not requested.

  4. A threshold definition that states that any suggested meeting time where 75% of the attendees are free is considered a Good meeting time.

  5. A window of suggested meeting times that includes today and tomorrow.

  6. A defined maximum number of nonworking hours as suggested meeting times per day; in this case, two.

  7. A maximum number of suggested meeting times per day; in this case, 10.

  8. A time span for suggested meeting times of 30 minutes.

  9. A minimum meeting quality time of Good.

  10. Four mailboxes to query for both free/busy information and suggested meeting times.

  11. A client application that has a locale in the Pacific Standard Time (PST) time zone and that observes daylight saving time.

The code example returns the free/busy information for each mailbox to the point that the caller has permission to view that data. It also returns a set of suggested meeting times that are organized by day and indicates the availability of the identified mailbox accounts.

static void GetUserAvailability(ExchangeServiceBinding esb)
{
    // Identify the options for comparing free/busy information.
    FreeBusyViewOptionsType fbViewOptions = new FreeBusyViewOptionsType();
    fbViewOptions.TimeWindow = new Duration();
    fbViewOptions.TimeWindow.StartTime = DateTime.Today;
    fbViewOptions.TimeWindow.EndTime = DateTime.Today.AddDays(2);
    fbViewOptions.RequestedView = FreeBusyViewType.DetailedMerged;
    fbViewOptions.RequestedViewSpecified = true;
    fbViewOptions.MergedFreeBusyIntervalInMinutes = 30;
    fbViewOptions.MergedFreeBusyIntervalInMinutesSpecified = true;

    // Define the suggestions view.
    SuggestionsViewOptionsType sugViewOptions = new SuggestionsViewOptionsType();
    sugViewOptions.GoodThreshold = 25;
    sugViewOptions.GoodThresholdSpecified = true;
    sugViewOptions.DetailedSuggestionsWindow = new Duration();
    sugViewOptions.DetailedSuggestionsWindow.StartTime = DateTime.Today;
    sugViewOptions.DetailedSuggestionsWindow.EndTime = DateTime.Today.AddDays(2);
    sugViewOptions.MaximumNonWorkHourResultsByDay = 2;
    sugViewOptions.MaximumNonWorkHourResultsByDaySpecified = true;
    sugViewOptions.MaximumResultsByDay = 10;
    sugViewOptions.MaximumResultsByDaySpecified = true;
    sugViewOptions.MeetingDurationInMinutes = 30;
    sugViewOptions.MeetingDurationInMinutesSpecified = true;
    sugViewOptions.MinimumSuggestionQuality = SuggestionQuality.Good;
    sugViewOptions.MinimumSuggestionQualitySpecified = true;

    // Identify the user mailboxes for which to review free/busy data.
    EmailAddress emailAddress0 = new EmailAddress();
    EmailAddress emailAddress1 = new EmailAddress();
    EmailAddress emailAddress2 = new EmailAddress();
    EmailAddress emailAddress3 = new EmailAddress();
    emailAddress0.Address = "user0@contoso.com";
    emailAddress1.Address = "user1@contoso.com";
    emailAddress2.Address = "user2@contoso.com";
    emailAddress3.Address = "user3@contoso.com";

    MailboxData[] mailboxes = new MailboxData[4];
    mailboxes[0] = new MailboxData();
    mailboxes[0].Email = emailAddress0;
    mailboxes[0].ExcludeConflicts = false;
    mailboxes[1] = new MailboxData();
    mailboxes[1].Email = emailAddress1;
    mailboxes[1].ExcludeConflicts = false;
    mailboxes[2] = new MailboxData();
    mailboxes[2].Email = emailAddress2;
    mailboxes[2].ExcludeConflicts = false;
    mailboxes[3] = new MailboxData();
    mailboxes[3].Email = emailAddress3;
    mailboxes[3].ExcludeConflicts = false;

    // Make the request.
    GetUserAvailabilityRequestType request = new GetUserAvailabilityRequestType();

    // Set the time zone of the request.
    request.TimeZone = new SerializableTimeZone();
    request.TimeZone.Bias = 480;
    request.TimeZone.StandardTime = new SerializableTimeZoneTime();
    request.TimeZone.StandardTime.Bias = 0;
    request.TimeZone.StandardTime.DayOfWeek = DayOfWeekType.Sunday.ToString();
    request.TimeZone.StandardTime.DayOrder = 1;
    request.TimeZone.StandardTime.Month = 11;
    request.TimeZone.StandardTime.Time = "02:00:00";
    request.TimeZone.DaylightTime = new SerializableTimeZoneTime();
    request.TimeZone.DaylightTime.Bias = -60;
    request.TimeZone.DaylightTime.DayOfWeek = DayOfWeekType.Sunday.ToString();
    request.TimeZone.DaylightTime.DayOrder = 2;
    request.TimeZone.DaylightTime.Month = 3;
    request.TimeZone.DaylightTime.Time = "02:00:00";

    // Add the mailboxes to the request.
    request.MailboxDataArray = mailboxes;

    // Add the free/busy view options to the request.
    request.FreeBusyViewOptions = fbViewOptions;

    // Add the suggested view options to the request.
    request.SuggestionsViewOptions = sugViewOptions;

    try
    {
        // Send the request and get the response.
        GetUserAvailabilityResponseType response = esb.GetUserAvailability(request);

        // Access free/busy information.
        if (response.FreeBusyResponseArray.Length < 1)
        {
            throw new Exception("No free/busy response data available.");
        }
        else
        {
            foreach (FreeBusyResponseType fbrt in response.FreeBusyResponseArray)
            {
                if (fbrt.ResponseMessage.ResponseClass == ResponseClassType.Error)
                {
                    Console.WriteLine(string.Format("Error: {0}", fbrt.ResponseMessage.MessageText));
                }
                else
                {
                    // TODO: Get the free/busy data and working hours.
                    FreeBusyView fbv = fbrt.FreeBusyView;
                }
            }
        }

        // Access suggested meeting times.
        SuggestionDayResult[] sdra = response.SuggestionsResponse.SuggestionDayResultArray;

        if (sdra.Length < 1)
        {
            throw new Exception("No suggested meeting times available.");
        }
        else
        {
            foreach (SuggestionDayResult sdr in sdra)
            { 
                // TODO: Get the suggested meeting times for each day.
            }
        }
    }
    catch (Exception e)
    {
        // TODO: Error processing.
        Console.WriteLine(e.Message);
    }
}

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.