Icalender is something like an open format text file to add items to the calendar (like Outlook calendar ). it is simply a text file which contains fields and information about the participates event of a calendar. once you double click on the icalendar file, the respective event gets registered in Outlook Calendar (Of course, with your approval for the event !). Following is the ASP. net code, which generates icalendar file dynamically (on the fly) and pushes the same to user. the user can either directly open it into outlook or simply save the icalendar file.
Protected SubButton#click (ByvalSenderAsSystem. object,ByvalEAsSystem. eventargs)HandlesButton1.click
DimSbAs NewStringbuilder (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)
DimENCAs NewUtf8encoding
DimArrbytdata ()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