We help IT Professionals succeed at work.

CDO Calendar List Appointment Info using Filter

rrsavage
rrsavage asked
on
am develeping an ASP Page to query an Outlook/Exchange Calendar for its Appointments using Microsoft's
CDO interface.  I need to filter the results down to a window of dates.  (i.e. Start Date, End Date).
 I am having difficulty getting the FILTER property to work in VBScript running on an ASP Server; however,
it works great in a VB Project.


Here is the working VBScript code with the filter section rem-ed out.

Thank You for your help.
RSavage


Sample.asp
----------------------------------------------------------
 ' establish object
 Set objCDOSession = CreateObject("MAPI.Session")
         
 ' login to MAPI session
 objCDOSession.Logon
   
 ' Get calendar
 Set objFolder = objCDOSession.GetDefaultFolder(0)
 Set objMessages = objFolder.Messages

 ''********************************************
 '' FILTER  (Start Date to End Date)
 Set objMessageFilter = objMessages.Filter
 'Set objField = _
 '            objFields.Add(cdoPR_START_DATE, "9/30/01")
 'Set objField = objFields.Add(CdoPR_END_DATE, "9/1/01")
 '
 '' Note! I have tried replacing the ENUMs with actual
 '' values, still didn't work ?????????????????
 ''********************************************
       
 ' Get appointments
 Set objAppointment = objMessages.GetFirst
   
 Do While Not objAppointment Is Nothing    
   response.write (objAppointment.StartTime & vbCrLf)

   'Next Appt
   Set objAppointment = objMessages.GetNext        
 Loop

 ' logout
 objCDOSession.Logoff
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2012
Commented:
Shouldn't the dates be defined as dates? i.e.:

Set objField = objFields.Add(cdoPR_START_DATE, #9/30/01#)
Set objField = objFields.Add(CdoPR_END_DATE, #9/1/01#)

Anthony
CERTIFIED EXPERT
Top Expert 2012

Commented:
Also, Option Explicit would catch if the enums were not defined, otherwise:

Const CdoPR_START_DATE = &H600040
Const CdoPR_END_DATE   = &H610040

and

Set objMessageFilter = objMessages.Filter
Set objFields = objMessageFilter.Fields  ' This line appears to be missing

Hope this helps,
Anthony
CERTIFIED EXPERT
Author of the Year 2009

Commented:
Hi rrsavage,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept acperkins@devx's comment(s) as an answer.

rrsavage, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.
==========
DanRollins -- EE database cleanup volunteer
Per recommendation, force-accepted by
Netminder
Community Support Moderator

Explore More ContentExplore courses, solutions, and other research materials related to this topic.