Windows Phone 7 - iCal Generator - C #

I need to generate an iCal string from the destinations received from the device. Is there any library that is supported on Windows Phone 7 to generate iCal from meetings?

I tried DDay.iCal , but it does not work with Windows Phone 7.

+5
source share
1 answer

There is no library for Windows Phone 7, but it’s not difficult for me to write my own classes for creating iCal files, since iCal is just text. The RFC is a pretty dense read , but using some online links like this and looking at some examples of iCal files should be enough to get started. Take this example iCal file from Wikipedia, for example:

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//hacksw/handcal//NONSGML v1.0//EN
BEGIN:VEVENT
UID:uid1@example.com
DTSTAMP:19970714T170000Z
ORGANIZER;CN=John Doe:MAILTO:john.doe@example.com
DTSTART:19970714T170000Z
DTEND:19970715T035959Z
SUMMARY:Bastille Day Party
END:VEVENT
END:VCALENDAR

So, note that you START and COMPLETE the VCALENDAR, and the VEVENT inside them, which has some required fields (e.g. UID). The only thing to note is that the specification requires strings to be longer than 75 octets, so you can use this method from this stack overflow question for fields with long text:

Private Function RFC2445TextField(ByVal LongText As String) As String

     LongText = LongText.Replace("\", "\\")
     LongText = LongText.Replace(";", "\;")
     LongText = LongText.Replace(",", "\,")


     Dim sBuilder As New StringBuilder
     Dim charArray() As Char = LongText.ToCharArray

     For i = 1 To charArray.Length
         sBuilder.Append(charArray(i - 1))
         If i Mod 74 = 0 Then sBuilder.Append(vbCrLf & " ")
     Next

     Return sBuilder.ToString

 End Function

escape- / 74 .

, !:)

+3

All Articles