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

推荐订阅源

Cisco Talos Blog
Cisco Talos Blog
量子位
小众软件
小众软件
Microsoft Azure Blog
Microsoft Azure Blog
V
Visual Studio Blog
I
InfoQ
Jina AI
Jina AI
The Cloudflare Blog
Recorded Future
Recorded Future
Recent Announcements
Recent Announcements
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
G
Google Developers Blog
Stack Overflow Blog
Stack Overflow Blog
阮一峰的网络日志
阮一峰的网络日志
Microsoft Security Blog
Microsoft Security Blog
美团技术团队
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Martin Fowler
Martin Fowler
T
Tailwind CSS Blog
博客园 - Franky
酷 壳 – CoolShell
酷 壳 – CoolShell
F
Fortinet All Blogs
WordPress大学
WordPress大学
P
Proofpoint News Feed
D
DataBreaches.Net
爱范儿
爱范儿
雷峰网
雷峰网
D
Docker
B
Blog
Engineering at Meta
Engineering at Meta
腾讯CDC
N
Netflix TechBlog - Medium
C
Check Point Blog
博客园 - 【当耐特】
Apple Machine Learning Research
Apple Machine Learning Research
T
Tenable Blog
GbyAI
GbyAI
Security Archives - TechRepublic
Security Archives - TechRepublic
博客园 - 三生石上(FineUI控件)
T
The Blog of Author Tim Ferriss
博客园 - 聂微东
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
SecWiki News
SecWiki News
S
Security @ Cisco Blogs
S
Security Affairs
V
V2EX
Application and Cybersecurity Blog
Application and Cybersecurity Blog
云风的 BLOG
云风的 BLOG
C
CERT Recently Published Vulnerability Notes
Y
Y Combinator 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