Generating icalender file using ASP. NET

Source: Internet
Author: User
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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.