惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

MongoDB | Blog
MongoDB | Blog
J
Java Code Geeks
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
D
DataBreaches.Net
腾讯CDC
GbyAI
GbyAI
I
InfoQ
博客园 - Franky
G
Google Developers Blog
Last Week in AI
Last Week in AI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
V
Visual Studio Blog
Vercel News
Vercel News
博客园_首页
MyScale Blog
MyScale Blog
Martin Fowler
Martin Fowler
N
Netflix TechBlog - Medium
V
V2EX
T
The Blog of Author Tim Ferriss
M
MIT News - Artificial intelligence
雷峰网
雷峰网
H
Hackread – Cybersecurity News, Data Breaches, AI and More
大猫的无限游戏
大猫的无限游戏
The GitHub Blog
The GitHub Blog

博客园 - Vincent Yang

Cannot load macro project error SQL Express - "Failed generate a user instance..." SQL Express 2008 x64 Integration with Visual Studio 2008 SP1 PowerShell Operators Crystal Reports .NET Error - "Access to report file denied. Another program may be using it." - Vincent Yang (转:)SharePoint Database Naming Standards List Types & List Internal ID available within MOSS 2007 Telerik: IIS7 & IIS 7.5 and ‘Telerik.Web.UI.WebResource.axd’ is missing in web config 64bit SQL Server issues : Connections to SQL Server files (*.mdf) require SQL Server Express 2005 to function properly 正式入住Windows 7 + XPM A Generic Singleton Form Provider for C# Extreme Programming: Do these 12 practices make perfect? Pick up the pace with extreme programming Testing an ASP.NET Web Service using PowerShell Parsing XML Files with PowerShell Testing SQL Stored Procedures using PowerShell Working with Collections of Objects using PowerShell SQL Server Precision And Scale Problems (SQL Server 精度问题) Six Quick Crystal Reports Design Tips
Generating iCalender file using ASP.NET
Vincent Yang · 2009-02-10 · via 博客园 - Vincent Yang

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 particular 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 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