Question

I need to be able to offer "downloadable" events for Outlook, via vCalendar objects - if I'm not mistaken.

From the research I've done, I've been pointed at using vObject. I've looked at their usage examples, but having no prior experience with the format, it's not clear to me how to solve my problem, as I'm not sure what fields are available, or what they're called...

Is there a straighforward example of creating an very simple object/vCalendar event with some type of name/description, that has a start and end time/date?

I'll be using Django, and will probably just dynamically create these for "download" as requested.

Was it helpful?

Solution

I believe the most useful fields are:

  • dtstart: start time
  • dtend: end time
  • summary
  • location
  • url
  • description

Then you create a calendar with:

cal = vobject.iCalendar()

then an event:

event = cal.add('vevent')

and populate it:

event.add('summary').value = 'your summary'
event.add('dtstart').value = datetime.now() # or anything else
...

Now if you want to return the calendar via http, you can use cal.serialize().

OTHER TIPS

Outlook 2003 seems to need a UID field for every VEVENT. the icalendar module doesn't seem to use these, so I've had to add the following snippets of code:

import uuid
...
event.add('uid',uuid.uuid4())

I was having the same issue on a Windows system. Once I replace crlfs with lfs things started working for me.

output = cal.serialize().replace(u'\r\n', u'\n' ).strip()
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top