views:

115

answers:

1

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.

+1  A: 

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().

Olivier
@Olivier Thanks! I'll be trying that out shortly!
anonymous coward
This works great creating the event, but for whatever reason, Outlook 2003 "cannot import vcalendar" when I attempt to import it, in various ways.
anonymous coward
Update: It seems to be that Outlook 2003 (at least on my box) doesn't like ics files that don't contain `METHOD:PUBLISH` somewhere before `BEGIN:VEVENT`. Works like a charm now. @Olivier: Thanks for the tips! I appreciate your time!
anonymous coward