logo

Printing Colons To Web From Notes Agent? Beware!

On of my many, many tasks today is to enable the output of a Notes-based view as an iCalendar (.ics) file, so uses can import it to the own calendar application.

To do this is simple. Just print the content-type "text/calendar" from the outputting agent and then print out all the entries in the required format.

I wrote the code to do this in very little time but then spent just as long wondering why on earth the content wasn't being outputted.

Then I realised what I'd done. Remember a couple of years ago I mentioned a way to print data to the content headers of a page? Inadvertently, that is what I had done.

Here's what my code looked like (simplified to prove a point):

Print "content-type: text/calendar"
Print "BEGIN:VCALENDAR"
Print "BEGIN:VEVENT"
Print "DTSTART;VALUE=DATE:20090909"
Print "END:VEVENT"
Print "BEGIN:VCALENDAR"

When I opened it in the browser all that was in the file downloaded was:

DTSTART;VALUE=DATE:20090909
END:VEVENT
BEGIN:VCALENDAR

After a maddening ten minutes or so I realised that all the lines after the content-type header were also being treated as headers. Firstly because they are in the format "XXX: yyyyy" i.e. a word followed by a colon. Secondly because I hadn't put a blank line between the header and the output. My code should (and does now) have looked like this:

Print "content-type: text/calendar"
Print ""
Print "BEGIN:VCALENDAR"
Print "BEGIN:VEVENT"
Print "DTSTART;VALUE=DATE:20090909"
Print "END:VEVENT"
Print "BEGIN:VCALENDAR"

There's a lesson in there somewhere!

iCalendar Format??

Didn't know you could export in a standard calendar format? Well, you can. Here's an example file which is based on this standard.

To output your Notes-stored dates in the right format you can do this:

Print "CREATED:"+Format(doc.Created, "yyyymmddThhMM00")

Although you might need to modify that if you want it accurate to the second or you're in a different timezone to GMT etc.

Comments

  1. Great post Jake!

    I've toyed with the idea of creating a sync widget for the Lotus Notes Client that would allow push/pull of calendar entries to Google Calender via iCalendar and the Google Calendar API. Just a matter of finding the time in the day.

    Perhaps we can suggest it and get it going as an openNTF project!

    • avatar
    • Keith
    • Wed 23 Sep 2009 12:45 PM

    Jake, could you send me a copy of the export agent? It's for personal use only....

    • avatar
    • Jake Howlett
    • Wed 23 Sep 2009 02:22 PM

    Likewise, if only I had the time Chris.

    It's on its way Keith.

  2. Jake nice hint. An altenative way to generate your ical files is to use a Java agent (or a servlet) which makes things a little easier (unless you are scared of Java, which we all know you are not). Easier because there is a ready made library available that allows you to just fill in the properties and it will take care of all the formatting and stuff for you. Check out:

    http://wiki.modularity.net.au/ical4j/index.php?title=Main_Page

    and of course you are aware of the calendaring schema documentation

    http://www.ibm.com/developerworks/lotus/documentation/dw-l-calendarschema.html

    • avatar
    • Jake Howlett
    • Thu 24 Sep 2009 04:00 AM

    Hadn't seen those links Stephan. Thanks. Very useful bookmarks!

Your Comments

Name:
E-mail:
(optional)
Website:
(optional)
Comment:


About This Page

Written by Jake Howlett on Wed 23 Sep 2009

Share This Page

# ( ) '

Comments

The most recent comments added:

Skip to the comments or add your own.

You can subscribe to an individual RSS feed of comments on this entry.

Let's Get Social


About This Website

CodeStore is all about web development. Concentrating on Lotus Domino, ASP.NET, Flex, SharePoint and all things internet.

Your host is Jake Howlett who runs his own web development company called Rockall Design and is always on the lookout for new and interesting work to do.

You can find me on Twitter and on Linked In.

Read more about this site »

More Content