Using iCal.net with Google Calendar

1.4k views Asked by At

I've replaced the DDay iCal library with iCal.Net in an application for scheduling officials. Many of the officials like to add their game calendar using "add from URL" on their Google calendar so they can see their schedule on their phones. It seems that Google calendar does not like the .ics file that is being produced now, however. It will import fine, but trying to add it by URL results in no events showing up. I've had no issues adding a link by URL with other clients (Outlook, O365, etc.), and the file appears normal in a text editor.

1

There are 1 answers

0
MDApache6 On BEST ANSWER

This issue appeared to be caused by the OpenTextFileWriter method including a Byte Order Mark (BOM) in the default ASCII encoding. Here is what the original code for producing this file looked like:

Dim MySerializer As New CalendarSerializer()
Dim file As System.IO.StreamWriter
file = My.Computer.FileSystem.OpenTextFileWriter(strPath, False)
file.Write(MySerializer.SerializeToString(MyCal))
file.Close()

I had to change my code that produced the ICS file to the following before Google Calendar and Apple's "Subscribe to this calendar" would work:

Dim MySerializer As New CalendarSerializer()
Dim file As System.IO.StreamWriter
Dim utf8WithoutBom As New System.Text.UTF8Encoding(False)
file = My.Computer.FileSystem.OpenTextFileWriter(strPath, False, utf8WithoutBom)
file.Write(MySerializer.SerializeToString(MyCal))
file.Close()

Interesting, Outlook and Office 365 was not picky about the BOM and it worked fine there.