Sdílet prostřednictvím


Rendering a Calendar to a Web Page (ADO)

Topic Last Modified: 2006-06-12

Example

VBScript

Note

The following example uses a file URL with the Exchange OLE DB (ExOLEDB) provider. The ExOLEDB provider also supports The HTTP: URL Scheme. Using The HTTP: URL Scheme allows both client and server applications to use a single URL scheme.

<!--
'Render calendar to a Web page with ADO
'This sample renders a calendar to a Web page using ADO
-->

<!--
'Build Instructions:
'1) Create a folder named "test" under inetpub/wwwroot.
'2) Save the following file in that folder with the mentioned name.
'3) Make the changes to the above file i.e. Change the calendarURL variable to reflect your mailbox and domain.
'4) Save the file.
'5) Open internet service manager and browse to the "test" folder.
'6) Right-click and go to properties.
'7) Go to the "Directory Security" tab.
'8) Click on "Edit" button next to the "handshake" icon.
'9) Uncheck "Anonymous Access".
'10) Check the "Basic authentication", "Digest authentication", and "Integrated Windows authentication".
'11) Click ok.
'12) Click ok.
'13) Load the asp in the browser.
-->

<%@ Language=VBScript%>
<%
    Dim CalendarURL
    Dim Rs
    Dim Rec
    Dim strSubject
    Dim strStartTime
    Dim strEndTime
   Dim strLocation

    Set Rs = CreateObject("ADODB.RecordSet")
    Set Rec = CreateObject("ADODB.Record")

    CalendarURL = "file://./backofficestorage/somedomain.example.com/MBX/user1/calendar/"

    Rec.Open CalendarURL

    Set Rs.ActiveConnection = Rec.ActiveConnection
    Rs.Source = "SELECT ""DAV:href"", " & _
                " ""urn:schemas:httpmail:subject"", " & _
                " ""urn:schemas:calendar:dtstart"", " & _
                " ""urn:schemas:calendar:dtend"", " & _
                " ""urn:schemas:calendar:location"" " & _
                "FROM scope('shallow traversal of """ & CalendarURL & """') " & _
                "WHERE (""urn:schemas:calendar:dtstart"" >=CAST(""2000-01-01T08:00:00Z"" as 'dateTime')) " & _
                "AND (""urn:schemas:calendar:dtend"" <=CAST(""2000-01-31T08:00:00Z"" as 'dateTime'))"


    Rs.Open
    Rs.MoveFirst
    Response.Write "<TABLE border=1>"
    Response.Write "<TR><TD>Subject</TD><TD>Start Time</TD><TD>End Time</TD><TD>Location</TD></TR>"
    Do Until Rs.EOF
        strSubject = Rs.Fields("urn:schemas:httpmail:subject").Value
        strStartTime = Rs.Fields("urn:schemas:calendar:dtstart").Value
        strEndTime = Rs.Fields("urn:schemas:calendar:dtend").Value
        strLocation = Rs.Fields("urn:schemas:calendar:location").Value

        response.write "<TR><TD>" & strSubject & "</TD><TD>" & strStartTime & "</TD><TD>" & strEndTime & "</TD><TD>" & strLocation & "</TD></TR>"
        Rs.MoveNext
    Loop
    Response.Write "</TABLE>"
    Set Rs = Nothing
    Set Rec = Nothing
%>