Skip to main content

Simple HTML calendar feed from Users Free/Busy data

A while ago I posted this about creating a simple html calendar like the ones you see in OWA. I was looking though some OWA captures today and noticed the following command is called when you manipulate the calender object in OWA.

?Cmd=monthfreebusy&start=2004-07-25T00:00:00+10:00&end=2004-09-05T00:00:00+10:00

(the +10:00 at the end I believe refers to the time zone offset which you need to adjust to your own timezone or put some code in that does it)

What this does is return a single string of numbers with each day in-between the &start and &end variables represented by a 0 if there are no appointments that day, a 1 if there is and a 2 is no freebusy data has been published.

I took this function and combined it with some WebDAV in a ASP page and was able to feed the simple html calendar and make it bold all the dates in the calendar that there where appointments on, I also created a few functions so you could change months back and forth.

The limitations of this method is that it only works for the months where free-busy information has been published and it doesn't work for public folder calendars because no free busy information is maintained for these. It should however come in handy for things like resource mailboxes where having a simple calendar comes in handy.

I've posted up a copy of the ASP page and button images here http://msgdev.mvps.org/exdevblog/showcalendar.zip (don't forget to change the timezone unless you live on the East coast of Aus)

The code itself look like


<table border="0" id="table1" cellpadding="2" width="147">
<tr><b>
<%
sdate = request.querystring("sdate")
if sdate = "" then
wdate = now()
mmonth = monthname(month(now())) & " " & Year(now())
else
wdate = dateserial(mid(sdate,1,4),mid(sdate,6,2),mid(sdate,9,2))
mmonth = monthname(month(wdate)) & " " & Year(wdate)
end if
pmonth = condate(dateadd("m",-1,wdate))
stime = condate(wdate)
etime = condate(dateadd("m",1,wdate))
response.write "<td style=""padding: 0"" width=""147"" align=""center"" colspan=""7""><b><font
face=""Arial Narrow"" size=2 color=""#000080"">"
response.write "<a href=""showcalendar.asp?sdate=" & etime & """><img
border=""0"" src=""pg-next.gif"" width=""16"" height=""16""
align=""right""></a>"
response.write "<a href=""showcalendar.asp?sdate=" & pmonth & """><img
border=""0"" src=""pg-prev.gif"" width=""16"" height=""16""
align=""left""></a><B>" & mmonth & "</b></td>"
%>
</font></b> </tr>
<tr>
<td style="border-bottom-style: solid; padding: 0" width="16" align="center">
M</td>
<td style="border-bottom-style: solid; padding: 0" width="16" align="center">
T</td>
<td style="border-bottom-style: solid; padding: 0" width="16" align="center">
W</td>
<td style="border-bottom-style: solid; padding: 0" width="16" align="center">
T</td>
<td style="border-bottom-style: solid; padding: 0" width="16" align="center">
F</td>
<td style="border-bottom-style: solid; padding: 0" width="16" align="center">
S</td>
<td style="border-bottom-style: solid; padding: 0" width="16" align="center">
S</td>
</tr>
<%

urlstr = "http://servername/exchange/mailbox/calendar/?Cmd=monthfreebusy&start="
& stime & "T00:00:00+10:00&end=" & etime & "T00:00:00+10:00"
Set Objxml = Server.CreateObject("Microsoft.XMLhttp")
Objxml.Open "Get", urlstr, False, "", ""
Objxml.setRequestHeader "Accept-Language:", "en-us"
Objxml.setRequestHeader "Content-type:", "application/x-www-UTF8-encoded"
Objxml.setRequestHeader "Content-Length:", Len(szXml)
Objxml.Send szXml
set oResponseDoc = Objxml.responseXML
set oNodeList = oResponseDoc.getElementsByTagName("fbdata")
For i = 0 To (oNodeList.length -1)
set oNode = oNodeList.nextNode
caldata = oNode.text
next
cdatefday = cdate(dateserial(year(wdate),month(wdate),"1"))
sday = weekday(cdatefday,2)
cmonth = month(wdate)
for x = 1 to 6
response.write "<tr>"
for i = 1 to 7
if cmonth = month(cdatefday) then
if sday =< i then
sday = 0
if mid(caldata,day(cdatefday),1) = 1 then
response.write "<td style=""padding: 0"" width=""16"" align=""center""><b>" &
day(cdatefday) & "</b></td>"
else
response.write "<td style=""padding: 0"" width=""16"" align=""center"">" &
day(cdatefday) & "</td>"
end if
cdatefday = dateadd("d",1,cdatefday)
else
response.write "<td style=""padding: 0"" width=""16"" align=""center""> </td>"

end if
else
response.write "<td style=""padding: 0"" width=""16"" align=""center""> </td>"

end if
next
response.write "</tr>"
next


function condate(date2con)
dtcon = date2con
if month(dtcon) < 10 then
if day(dtcon) < 10 then
qdat = year(dtcon) & "-" & "0" & month(dtcon) & "-" & "01"
else
qdat = year(dtcon) & "-" & "0" & month(dtcon) & "-" & "01"
end if
else
if day(dtcon) < 10 then
qdat = year(dtcon) & "-" & month(dtcon) & "-" & "01"
else
qdat = year(dtcon) & "-" & month(dtcon) & "-" & "01"
end if
end if
condate = qdat
end function
%>

Popular posts from this blog

Sending a Message in Exchange Online via REST from an Arduino MKR1000

This is part 2 of my MKR1000 article, in this previous post  I looked at sending a Message via EWS using Basic Authentication.  In this Post I'll look at using the new Outlook REST API  which requires using OAuth authentication to get an Access Token. The prerequisites for this sketch are the same as in the other post with the addition of the ArduinoJson library  https://github.com/bblanchon/ArduinoJson  which is used to parse the Authentication Results to extract the Access Token. Also the SSL certificates for the login.windows.net  and outlook.office365.com need to be uploaded to the devices using the wifi101 Firmware updater. To use Token Authentication you need to register an Application in Azure https://msdn.microsoft.com/en-us/office/office365/howto/add-common-consent-manually  with the Mail.Send permission. The application should be a Native Client app that use the Out of Band Callback urn:ietf:wg:oauth:2.0:oob. You ...

The MailboxConcurrency limit and using Batching in the Microsoft Graph API

If your getting an error such as Application is over its MailboxConcurrency limit while using the Microsoft Graph API this post may help you understand why. Background   The Mailbox  concurrency limit when your using the Graph API is 4 as per https://docs.microsoft.com/en-us/graph/throttling#outlook-service-limits . This is evaluated for each app ID and mailbox combination so this means you can have different apps running under the same credentials and the poor behavior of one won't cause the other to be throttled. If you compared that to EWS you could have up to 27 concurrent connections but they are shared across all apps on a first come first served basis. Batching Batching in the Graph API is a way of combining multiple requests into a single HTTP request. Batching in the Exchange Mail API's EWS and MAPI has been around for a long time and its common, for email Apps to process large numbers of smaller items for a variety of reasons.  Batching in the Gr...

Exporting and Uploading Mailbox Items using Exchange Web Services using the new ExportItems and UploadItems operations in Exchange 2010 SP1

Two new EWS Operations ExportItems and UploadItems where introduced in Exchange 2010 SP1 that allowed you to do a number of useful things that where previously not possible using Exchange Web Services. Any object that Exchange stores is basically a collection of properties for example a message object is a collection of Message properties, Recipient properties and Attachment properties with a few meta properties that describe the underlying storage thrown in. Normally when using EWS you can access these properties in a number of a ways eg one example is using the strongly type objects such as emailmessage that presents the underlying properties in an intuitive way that's easy to use. Another way is using Extended Properties to access the underlying properties directly. However previously in EWS there was no method to access every property of a message hence there is no way to export or import an item and maintain full fidelity of every property on that item (you could export the...
All sample scripts and source code is provided by for illustrative purposes only. All examples are untested in different environments and therefore, I cannot guarantee or imply reliability, serviceability, or function of these programs.

All code contained herein is provided to you "AS IS" without any warranties of any kind. The implied warranties of non-infringement, merchantability and fitness for a particular purpose are expressly disclaimed.