views:

8355

answers:

6

I'm looking for a good method of generating an iCalendar file (*.ics) in c# (asp.net). I've found a couple resources, but one thing that has been lacking is their support for quoted-printable fields - fields that have carriage returns and line feeds.

For example, if the description field isn't encoded properly, only the first line will display and possibly corrupting the rest of the information in the *.ics file.

I'm looking for existing classes that can generate *.ics files and/or a class that can generate quoted-printable fields.

+23  A: 

I use DDay.Ical, its good stuff. Has the ability to open up an ical file and get its data in a nice object model. It says beta, but it works great for us.

DevelopingChris
A: 

iCal can be complicated, so I recommend using a library. DDay is a good free solution. Last I checked it didn't have full support for recurring events, but other than that it looks really nice. Definitely test the calendars with several clients.

Lance Fisher
A: 

Check out http://www.codeproject.com/KB/vb/vcalendar.aspx

It doesn't handle the quoted-printable fields like you asked, but the rest of the code is there and can be modified.

slolife
+5  A: 

The easiest way I've found of doing this is to markup your HTML using microformats.

If you're looking to generate iCalendar files then you could use the hCalendar microformat then include a link such as 'Add to Calendar' that points to:

http://feeds.technorati.com/events/[ your page's full URL including the http:// ]

The Technorati page then parses your page, extracts the hCalendar info and sends the iCalendar file to the client.

Ian Oxley
This method is used by NerdDinner.com and seems to work quite nicely. That said, I've got to give +1 for DDay.iCal (although I *am* biased) :)
Doug
A: 

According to RFC-2445, the comment and description fields are TEXT. The rules for a test field are: [1] A single line in a TEXT field is not to exceed 75 octets. [2] Wrapping is achieved by inserting a CRLF followed by whitespace. [3] There are several characters that must be encoded including \ (reverse slash) ; (semicolon) , (comma) and newline. Using a \ (reverse slash) as a delimiter gives \ \; \, \n

Example: The following is an example of the property with formatted line breaks in the property value:

 DESCRIPTION:Meeting to provide technical review for "Phoenix"
   design.\n Happy Face Conference Room. Phoenix design team
   MUST attend this meeting.\n RSVP to team leader.
+1  A: 

iCal (ical 2.0) and quoted-printable don't go together.

Quoted-printable is used a lot in vCal (vCal 1.0) to represent non-printable characters, e.g. line-breaks (=0D=0A). The default vCal encoding is 7-bit, so sometimes you need to use quoted-printable to represent non-ASCII characters (you can override the default encoding, but the other vCal-compliant communicating party is not required to understand it.)

In iCal, special characters are represented using escapes, e.g. '\n'. The default encoding is UTF-8, all iCal-compliant parties must support it and that makes quoted-printable completely unnecessary in iCal 2.0 (and vCard 3.0, for that matter).

You may need to back your customer/stakeholder to clarify the requirements. There seems to be confusion between vCal and iCal.

azheglov