Feb 8, 2006 I recently build a web application that would let visitors add calendar items to their
calendar program like Outlook or windows mobile smartphone, just by clicking a link
and download the vCalendar item. vCalendar is a standard format for calendar items
and is used widely across the industry by most calendar programs and tools. It is
actually a simple text file, so it is not hard to create them dynamically. This is
an example of a method in VB.NET that converts an ASP.NET page into a vCalendar item.
Just call the method from the page load or use it in a httphandler.
Private Sub vCalendar(ByVal subject As String, ByVal location As String, ByVal description As String, ByVal dateStart As Date, ByVal dateEnd As Date)
Dim mStream As New System.IO.MemoryStream
Dim writer As New System.IO.StreamWriter(mStream, System.Text.Encoding.GetEncoding(1252))
With writer
.AutoFlush = True
.WriteLine("BEGIN:VCALENDAR")
.WriteLine("PRODID:-//Mads
Kristensen//DA")
.WriteLine("BEGIN:VEVENT")
.WriteLine("DTSTART:" & dateStart.ToUniversalTime.ToString("yyyyMMdd\THHmmss\Z"))
.WriteLine("DTEND:" & dateEnd.ToUniversalTime.ToString("yyyyMMdd\THHmmss\Z"))
.WriteLine("LOCATION:" & location)
.WriteLine("DESCRIPTION;ENCODING=QUOTED-PRINTABLE:" & description)
.WriteLine("SUMMARY:" & subject)
.WriteLine("PRIORITY:3")
.WriteLine("END:VEVENT")
.WriteLine("END:VCALENDAR")
End With
With Response
.ClearHeaders()
.AppendHeader("Content-Disposition", "attachment; filename=" & subject & ".vcs")
.AppendHeader("Content-Length", mStream.Length.ToString())
.ContentType = "text/calendar"
.BinaryWrite(mStream.ToArray())
.End()
End With
End Sub
See
an example vCalender item>
if you are looking for vCard implementation too, here's
one.
* $4.95/month BlogEngine.net Hosting – Click Here!