HOWTO: Write a VBScript MessageFilter in an ASP Page

Last reviewed: January 6, 1998
Article ID: Q178509
The information in this article applies to:
  • Collaboration Data Objects (CDO), version 1.2
  • Microsoft Active Server Pages, versions 1.0, 1.0b

SUMMARY

You can use a message filter in an Active Server Page (ASP) utilizing Microsoft Visual Basic Script (VBScript) to filter your appointment calendar. This article contains sample code that demonstrates how to use VBScript for the message filter.

MORE INFORMATION

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

   http://www.microsoft.com/support/supportnet/refguide/default.asp

Sample Code

Create a new ASP file and paste the following code into the ASP file:

   <%@ LANGUAGE="VBSCRIPT" %>

   <HTML>
   <HEAD>
   <META NAME="GENERATOR" Content="Microsoft Visual InterDev 1.0">
   <META HTTP-EQUIV="Content-Type" content="text/html;charset=iso-8859-1">
   <TITLE>Document Title</TITLE>
   </HEAD>
   <BODY>
   <%
   Const strServer                 = "MyExchangeServer"
   Const strMailbox                = "MyMailbox"
   Const CdoDefaultFolderCalendar  = 0
   Const CdoPR_START_DATE          = &H600040
   Const CdoPR_END_DATE            = &H610040
   Dim objSession
   Dim objCalendarFolder
   Dim objAppointments
   Dim objAppointmentFilter
   Dim objOneAppointment
   Dim strProfileInfo
   Dim StartTime
   Dim EndTime
   Dim objAppointmentFilterField1
   Dim objAppointmentFilterField2

   strProfileInfo = strServer & vbLf & strMailbox
   Set objSession = Server.CreateObject("MAPI.Session")
   objSession.Logon , , False, False, 0, True, strProfileInfo

   'Fill in a date/time using a vbDate format.
   'For example, StartTime = #1/1/98 9:30 AM#. This vbDate
   'filters appointments that started AFTER 9:30 AM on
   'January 1, 1998. Use StartTime and EndTime in combination
   'to filter a specific date. For example, if you wanted to filter
   'all your appointments on January 1, 1998, you would use
   'StartTime = #1/1/98#
   'EndTime = #1/2/98#
   'This combination filters all appointments starting
   'AFTER Janury 1, 1998 at midnight, and all appointments ending
   'BEFORE January 2, 1998 at midnight.
   'You can further refine your filter by adding times to the
   'StartTime and EndTime.
   StartTime = #12/18/97 2:00:00 PM#
   EndTime = #12/19/97#
   Set objCalendarFolder = _
     objSession.GetDefaultFolder(CdoDefaultFolderCalendar)
   Set objAppointments = objCalendarFolder.Messages
   Set objAppointmentFilter = objAppointments.Filter

   'NOTE: Use the EndTime in the Start_Date field and the
   'StartTime in the End_Date field.
   Set objAppointmentFilterField1 = _
     objAppointmentFilter.Fields.Add(CdoPR_START_DATE, EndTime)
   Set objAppointmentFilterField2 = _
     objAppointmentFilter.Fields.Add(CdoPR_END_DATE, StartTime)

   For Each objOneAppointment In objAppointments
     Response.Write("objOneAppointment.Subject = " & _
             objOneAppointment.Subject & "<br>")
     Response.Write("objOneAppointment.StartTime = " & _
             objOneAppointment.StartTime & "<br>")
     Response.Write("objOneAppointment.EndTime = " & _
             objOneAppointment.EndTime & " <br>")
     Response.Write("objOneAppointment.Duration = " & _
             objOneAppointment.Duration & "<br> <br>")
   Next
   Response.Write("Done <br>")
   objSession.Logoff
   Set objOneAppointment = Nothing
   Set objAppointments = Nothing
   Set objCalendarFolder = Nothing
   Set objSession = Nothing
   %>

   </BODY>
   </HTML>

Keywords          : kbcode cdo kbInetDev AXSFVBS
Version           : WINDOWS:1.2; WINNT:1.0,1.0b
Platform          : WINDOWS winnt
Issue type        : kbhowto


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: January 6, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.