views:

324

answers:

0

I am new to this, I am trying to save a reminder to outlook. But it is not doing anything. Wondering what is wrong in my code. Here is my code

DownloadAsVCS(BuildVCSFile(sVcalType, sVcalDate))

    Public Function BuildVCSFile(ByVal sVcalType As String, ByVal sVcalDate As String) As String

        Dim beginDate As Date = #1/7/2005 4:00:00 PM#
        Dim endDate As Date = #1/7/2005 6:00:00 PM#

        Dim sb As New StringBuilder
        sb.Append("BEGIN:VCALENDAR")
        sb.Append(Environment.NewLine)
        sb.Append("VERSION:2.0")
        sb.Append(Environment.NewLine)
        sb.Append("CALSCALE:GREGORIAN")
        sb.Append(Environment.NewLine)
        sb.Append("METHOD:PUBLISH")
        sb.Append(Environment.NewLine)
        sb.Append("BEGIN:VEVENT")
        sb.Append(Environment.NewLine)

        'Dim date_start As Date = sVcalDate.ToString()
        'Dim date_timeStart As Date = timeStart.Date.ToUniversalTime
        'sb.Append(String.Format("DTSTART:{0}{1}{2}T{3}{4}00Z", Year(date_start).ToString, GetAsTwoDigit(Month(date_start).ToString), GetAsTwoDigit(Day(date_start).ToString), GetAsTwoDigit(Hour(date_timeStart).ToString), GetAsTwoDigit(Minute(date_timeStart).ToString)))

        'Dim date_end As Date = calDtEnd.SelectedDate
        'Dim date_timeEnd As Date = timeEnd.Date.ToUniversalTime
        'sb.Append(String.Format("DTEND:{0}{1}{2}T{3}{4}00Z", Year(date_end).ToString, GetAsTwoDigit(Month(date_end).ToString), GetAsTwoDigit(Day(date_end).ToString), GetAsTwoDigit(Hour(date_timeEnd).ToString), GetAsTwoDigit(Minute(date_timeEnd).ToString)))

        sb.Append("DTSTART:" & beginDate.ToUniversalTime.ToString("yyyyMMdd\THHmmss\Z"))
        sb.Append(Environment.NewLine)
        sb.Append("DTEND:" & endDate.ToUniversalTime.ToString("yyyyMMdd\THHmmss\Z"))
        sb.Append(Environment.NewLine)

        sb.Append(String.Format("LOCATION;ENCODING=QUOTED-PRINTABLE:{0}", "TEST LOCATION"))
        sb.Append(Environment.NewLine)
        sb.Append("UID:    FD7D9F229CAE422AA76738B77044DA9659A83")
        sb.Append(Environment.NewLine)
        sb.Append(String.Format("DESCRIPTION;ENCODING=QUOTED-PRINTABLE:{0}", "TEST DESCRIPTION"))
        sb.Append(Environment.NewLine)
        sb.Append(String.Format("SUMMARY;ENCODING=QUOTED-PRINTABLE:{0}", "TEST SUMMARY"))
        sb.Append(Environment.NewLine)
        sb.Append(String.Format("PRIORITY:{0}", "1"))
        sb.Append(Environment.NewLine)
        sb.Append("End : VEVENT")
        sb.Append(Environment.NewLine)
        sb.Append("End : VCALENDAR")
        Return sb.ToString

    End Function

Private Sub DownloadAsVCS(ByVal text As String) Try Response.Clear() Response.Buffer = True Response.ContentType = "text/x-vcalendar" Response.AddHeader("Content-disposition", String.Format("filename={0}", Download_VCS_FileName)) Response.AppendHeader("Content-Length", text.Length.ToString()) Response.Write(text) Response.End() Catch ex As Exception

        End Try

    End Sub