Generating iCalender file using ASP.NET
Protected Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim sb As New StringBuilder(215)
sb.AppendFormat("BEGIN:VCALENDAR{0}", Environment.NewLine)
sb.AppendFormat("CALSCALE:GREGORIAN{0}", Environment.NewLine)
sb.AppendFormat("VERSION:1.0{0}", Environment.NewLine)
sb.AppendFormat("BEGIN:VEVENT{0}", Environment.NewLine)
sb.AppendFormat("DTSTART:20080703T093000{0}", Environment.NewLine)
sb.AppendFormat("DTEND:20080703T113000{0}", Environment.NewLine)
sb.AppendFormat("LOCATION:testing some location{0}", Environment.NewLine)
sb.AppendFormat("SUMMARY:Testing Some subject{0}", Environment.NewLine)
sb.AppendFormat("CLASS:PUBLIC{0}", Environment.NewLine)
sb.AppendFormat("END:VEVENT{0}", Environment.NewLine)
sb.AppendFormat("END:VCALENDAR{0}", Environment.NewLine)
Dim enc As New UTF8Encoding
Dim arrBytData() As Byte = enc.GetBytes(sb.ToString)
Response.Clear()
Response.ContentType = "text/plain"
Response.AppendHeader("Content-Disposition", "attachment; filename=vCalendar.ics")
Response.AppendHeader("Content-Length", arrBytData.Length.ToString())
Response.ContentType = "application/octet-stream"
Response.BinaryWrite(arrBytData)
Response.Flush()
Response.End()
End Sub
End Class