GetUserAvailabilityRequestType Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
The GetUserAvailabilityRequestType class represents an operation to get the availability information for a user.
public ref class GetUserAvailabilityRequestType : ExchangeWebServices::BaseRequestType
public class GetUserAvailabilityRequestType : ExchangeWebServices.BaseRequestType
Public Class GetUserAvailabilityRequestType
Inherits BaseRequestType
- Inheritance
Examples
The following code example shows you a GetUserAvailability query that includes the following elements:
- A time window for free/busy data that includes today and tomorrow.
- 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.
- 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.
- A threshold definition that states that any suggested meeting time where 75% of the attendees are free is considered a Good meeting time.
- A window of suggested meeting times that includes today and tomorrow.
- A defined maximum number of nonworking hours as suggested meeting times per day; in this case, two.
- A maximum number of suggested meeting times per day; in this case, 10.
- A time span for suggested meeting times of 30 minutes.
- A minimum meeting quality time of Good.
- Four mailboxes to query for both free/busy information and suggested meeting times.
- 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 <span class="label">request</span> = new GetUserAvailabilityRequestType();
// Set the time zone of the request.
<span class="label">request</span>.TimeZone = new SerializableTimeZone();
<span class="label">request</span>.TimeZone.Bias = 480;
<span class="label">request</span>.TimeZone.StandardTime = new SerializableTimeZoneTime();
<span class="label">request</span>.TimeZone.StandardTime.Bias = 0;
<span class="label">request</span>.TimeZone.StandardTime.DayOfWeek = DayOfWeekType.Sunday.ToString();
<span class="label">request</span>.TimeZone.StandardTime.DayOrder = 1;
<span class="label">request</span>.TimeZone.StandardTime.Month = 11;
<span class="label">request</span>.TimeZone.StandardTime.Time = "02:00:00";
<span class="label">request</span>.TimeZone.DaylightTime = new SerializableTimeZoneTime();
<span class="label">request</span>.TimeZone.DaylightTime.Bias = -60;
<span class="label">request</span>.TimeZone.DaylightTime.DayOfWeek = DayOfWeekType.Sunday.ToString();
<span class="label">request</span>.TimeZone.DaylightTime.DayOrder = 2;
<span class="label">request</span>.TimeZone.DaylightTime.Month = 3;
<span class="label">request</span>.TimeZone.DaylightTime.Time = "02:00:00";
// Add the mailboxes to the request.
<span class="label">request</span>.MailboxDataArray = mailboxes;
// Add the free/busy view options to the request.
<span class="label">request</span>.FreeBusyViewOptions = fbViewOptions;
// Add the suggested view options to the request.
<span class="label">request</span>.SuggestionsViewOptions = sugViewOptions;
try
{
// Send the request and get the response.
GetUserAvailabilityResponseType response = esb.GetUserAvailability(<span class="label">request</span>);
// 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);
}
}
Remarks
The order in which mailboxes are added to the request represents the order in which mailbox information is received in the response.
Constructors
GetUserAvailabilityRequestType() |
The GetUserAvailabilityRequestType constructor initializes an instance of the GetUserAvailabilityRequestType class. |
Properties
FreeBusyViewOptions |
The FreeBusyViewOptions property gets or sets the free/busy view options for an availability query. This property is optional unless the SuggestionsViewOptions property is not set. This is a read/write property. |
MailboxDataArray |
The MailboxDataArray property gets or sets the list of mailboxes to search for an availability query. |
SuggestionsViewOptions |
The SuggestionsViewOptions property gets or sets the options for meeting suggestion information for an availability query. This property is optional unless the FreeBusyViewOptions property is not set. This is a read/write property. |
TimeZone |
The TimeZone property gets or sets the client's time zone information. This includes the transition between standard time and daylight saving time. |