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

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 Graph is limited to a m

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 need to authorize it in you tenant (eg build a small ap

How to test SMTP using Opportunistic TLS with Powershell and grab the public certificate a SMTP server is using

Most email services these day employ Opportunistic TLS when trying to send Messages which means that wherever possible the Messages will be encrypted rather then the plain text legacy of SMTP.  This method was defined in RFC 3207 "SMTP Service Extension for Secure SMTP over Transport Layer Security" and  there's a quite a good explanation of Opportunistic TLS on Wikipedia  https://en.wikipedia.org/wiki/Opportunistic_TLS .  This is used for both Server to Server (eg MTA to MTA) and Client to server (Eg a Message client like Outlook which acts as a MSA) the later being generally Authenticated. Basically it allows you to have a normal plain text SMTP conversation that is then upgraded to TLS using the STARTTLS verb. Not all servers will support this verb so if its not supported then a message is just sent as Plain text. TLS relies on PKI certificates and the administrative issue s that come around certificate management like expired certificates which is why I wrote th
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.