Creating a Microsoft Office Outlook Appointment using Asp.net

Fungus1487 0 Tallied Votes 209 Views Share

This is a very brief overview of how to achieve an ON-THE-FLY creation of an appointment in the clients outlook calendar. This will not force the user to add it to there calendar but gives them the option to add it automated. Using the older .vcs file extension for outlook we can add an appointment easily by creating this document and letting hte user open it via the web. I have used the .vcs extension as it is compatible with older versions of outlook (mine being 2002) and not just 2007 +

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim outlookvcs As New System.Text.StringBuilder
        Dim subject As String
        Dim content As String
        Dim startdate As DateTime
        Dim enddate As DateTime

        ' SET SUBJECT HEADER
        subject = "TESTING"

        ' SET CONTENT [use '=0D' to make outlook perform a line break]
        content = "There is some content here"

        ' SET DATES
        startdate = New DateTime(2007, 12, 25, 12, 0, 0)
        enddate = New DateTime(2007, 12, 25, 19, 30, 0)

        With outlookvcs
            .Append("BEGIN:VCALENDAR" & vbLf)
            .Append("PRODID:-//Microsoft Corporation//Outlook 10.0 MIMEDIR//EN" & vbLf)
            .Append("VERSION:1.0" & vbLf)
            .Append("BEGIN:VEVENT" & vbLf)
            .Append("DTSTART:" & str_outlookdate(startdate) & "T" & str_outlooktime(startdate) & "Z" & vbLf)
            .Append("DTEND:" & str_outlookdate(enddate) & "T" & str_outlooktime(enddate) & "Z" & vbLf)
            .Append("UID:1" & vbLf)
            .Append("DESCRIPTION;ENCODING=QUOTED-PRINTABLE:" & content & "=0A" & vbLf)
            .Append("SUMMARY;ENCODING=QUOTED-PRINTABLE:" & subject & vbLf)
            .Append("PRIORITY:3" & vbLf)
            .Append("END:VEVENT" & vbLf)
            .Append("END:VCALENDAR" & vbLf)
        End With

        Response.Clear()
        Response.ContentType = "text/calendar"
        Response.AddHeader("content-disposition", "attachment; filename=outlook_calendar_appointment.vcs")
        Response.Write(outlookvcs)
        Response.End()
    End Sub

    Private Function str_outlookdate(ByVal dat_date As Date) As String
        str_outlookdate = Format(dat_date, "yyyyMMdd")
    End Function

    Private Function str_outlooktime(ByVal dat_time As Date) As String
        str_outlooktime = Format(dat_time, "HHmmss")
    End Function
elf123 0 Newbie Poster

When I try the previous code to send an appointment to an Outlook calendar,
I get an error message in the code that says --Name 'Response' is not declared.-- I would very mush like for this to work. Any help would be greatly appreciated. Thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.