Checking Free/Busy Status (HTTP)

Checking Free/Busy Status (HTTP)

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

Before you send a meeting request, you can check an attendee's calendar to see when the attendee is available. The freebusy method returns a string of numbers that indicate the attendee's availability for a requested period of time and can be submitted as a URL command over HTTP.

The freebusy command takes four command parameters:

  • start - the starting time of the range to determine free/busy status.
  • end - the ending time of the range to determine free/busy status.
  • interval - the interval, in minutes, of the free/busy time to download. Must be greater than or equal to one minute.
  • u - the SMTP e-mail address of the user whose free/busy info is being retrieved.

Each number in the free/busy string represents an interval of time, for example 60 minutes. Free time returns 0, Tentative returns 1, Busy returns 2, and Out of Office (OOF) returns 3. If appointments overlap, the highest number is returned. If no free/busy data is available for the interval, the value 4 is returned.

Note  An automated process in Microsoft® Exchange Server 2003 periodically updates the free/busy status of users. Microsoft Outlook® updates the free/busy status of Outlook users. Collaboration Data Objects (CDO) synchronizes the Outlook free/busy cache with free/busy information from CDO clients. The free/busy status is not updated immediately when a meeting is added to a user's calendar. By default, three months' worth of free/busy status is maintained in a system folder in the Exchange store.

VBScript

The following example returns the free/busy status of the specified user:

Option Explicit

' Variables
Dim strServer           ' As String
Dim strUser             ' As String
Dim strUrl              ' As String
Dim request             ' As MSXML2.XMLHTTP
Dim doc                 ' As MSXML2.DOMDocument
Dim objNodeList         ' As IXMLDOMNodeList
Dim objItemNode         ' As IXMLDOMNode
Dim objDisplayNode      ' As IXMLDOMNode
Dim objFBNode           ' As IXMLDOMNode

' Initialize variables.
' The public folder server that contains the user's free/busy information.
strServer = "servername"

' The user's e-mail address.
strUser = "user@example.com"

' Build the URL with the freebusy command.  Specify a start date/time of
' 08:00 (UTC) 27 Sep 2004, an end date/time of 20:00 (UTC) 27 Sep 2004, an
' interval of 60 minutes, and the e-mail address of the user.  Multiple
' e-mail addresses can be specified by appending one or more
' "&u=SMTP:user@example.com" command parameter values to the URL string.
strUrl="http://" & strServer & "/public/?cmd=freebusy" & _
     "&start=2004-09-27T08:00:00Z" & _
     "&end=2004-09-27T20:00:00Z" & _
     "&interval=60" & _
     "&u=SMTP:" & strUser ' & "&u=SMTP:user2@example.com"

' Initialize the XMLHTTP object.
set request=createobject("Msxml2.XMLHTTP")

' Open the request object with the GET method and
' specify that it will be sent asynchronously.
request.open "GET", strUrl, false

' Set the Content-Type header.
request.setRequestHeader "Content-Type", "text/xml"

' Set the Content-Length header.
request.setRequestHeader "Content-Length", 0

' Set the Accept-language header.
request.setRequestHeader "Accept-Language", "en-us"

' Send the GET method request.
request.send ""

' The request was successful.
If 200 = request.status Then
   ' Uncomment this line to see the XML response.
   ' wscript.echo request.responsetext

   ' Create the DOM document.
   Set doc=createobject("msxml2.domdocument")

   ' Load the XML response body.
   If doc.loadXml(request.ResponseText) Then

      ' Build a list of the WM:item XML nodes, corresponding to the
      ' returned user and free/busy information of the freebusy
      ' command.  The WM: namespace is typically assigned the a: prefix
      ' in the XML response body.  The namespaces and their associated
      ' prefixes are located in the attributes of the WM:response node
      ' of the XML response.
      Set objNodeList=doc.selectNodes("//a:item")

      ' Iterate through the WM:item nodes.
      For Each objItemNode In objNodeList

         ' Use an XPath query to get the WM:displayname node
         ' from the WM:item node.
         set objDisplayNode = objItemNode.selectSingleNode("a:displayname")

         ' Use an XPath query to get the WM:fbdata node
         ' from the WM:item node.
         set objFBNode = objItemNode.selectSingleNode("a:fbdata")

         ' Display free/busy information.
         wscript.echo "Display name: " & objDisplayNode.Text
         wscript.echo "Free/busy data: " & objFBNode.Text
         wscript.echo ""
      Next
   End If

Else
    wscript.echo request.status & " " & request.statustext
End if

' Clean up.
Set request = nothing
Set doc = nothing

Send us your feedback about the Microsoft Exchange Server 2003 SDK.

This topic last updated: September 2004

Build: June 2007 (2007.618.1)

© 2003-2006 Microsoft Corporation. All rights reserved. Terms of use.