Processing meeting cancellations using CDO/WebDAV

Anything VBScript-related, including Windows Script Host, WMI, ADSI, and more.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 16 years and 9 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
jgirotto
Posts: 4
Last visit: Thu Apr 17, 2008 4:45 am

Processing meeting cancellations using CDO/WebDAV

Post by jgirotto »

I'm trying to write a script to process meeting cancellations. Exchange mailboxes do not process meeting cancellations without some agent acting on it (from what I've read), so, even though free/busy data shows correctly, the display of a conference room can become quite a mess.

There is a good amount of information on the web about this and I read a lot of it. I have taken my code from this link and tried it in VBScript and Visual Basic:
http://msdn2.microsoft.com/en-us/library/aa488391.aspx

However, I am not able to get it to run properly. I get the following error:

The error I get is:
Microsoft VBScript runtime error: ActiveX component can't create object: 'CDO.ICalendarPart'

When trying to instantiate this object. I've tried CDOEX and other varations.

I have the ESM tools insalled on my machine and am running the code in a privileged account. I have copied the cdoex.dll from an Exchange server to my workstation and registered it. I have also run the code on the exchange server where the mailbox resides - same error. I guess it is not a CDO object. I've actually tried a number of things and generated a fun assortment of errors.

Since the code from the website is provided in Visual Basic, I tried that. No matter what references I add in Visual Studio, it does not recognize the CalendarMessage, ICalendarPart, CdoDAV.cdoHref, etc. I read something about the CDOEX being available via CDO through an interop and I tried some things in that area, but no success as yet. I'm hitting my ceiling in terms of expertise, so I need help.

Here is the code, where <MyUserName>, <server> and <my primary SMTP address> are replaced with actual values. I'm not using the M drive as you can see.

Code: Select all

Dim InboxURL     ' As String
Dim CalendarURL  ' As String
Dim ItemURL      ' As String
Dim Rs
Set Rs = CreateObject("ADODB.Recordset")
Dim Rec
Set Rec = CreateObject("ADODB.Record")
Dim iCalMsg
Set iCalMsg = CreateObject("CDO.CalendarMessage")
Dim iCalPart     ' As     ICalendarPart
Set iCalPart = CreateObject("CDO.ICalendarPart")
Dim iAppt
Set iAppt = CreateObject("CDO.Appointment")
Dim Index        ' As     Integer
Dim ContentClass ' As     String
Dim Config
Set Config = CreateObject("CDO.Configuration")
InboxURL = "/Exchange/<MyUserName>/Inbox">http://<server>/Exchange/<MyUserName>/Inbox"
CalendarURL = "/Exchange/<MyUserName>/Calendar">http://<server>/Exchange/<MyUserName>/Calendar"
'Set the configuration fields for the appointment objects
Config.Fields("cdoSendEmailAddress") = "<my primary SMTP address>"
Config.Fields("CalendarLocation") = CalendarURL
Config.Fields.Update
'Open a recordset for the items in the inbox folder
Rec.Open InboxURL
Set Rs.ActiveConnection = Rec.ActiveConnection
Rs.Source = "select ""DAV:href"",""DAV:contentclass"" from scope('shallow traversal of """ & InboxURL & """')"
Rs.Open
'Enumerate the recordset, checking each item's content class
Rs.MoveFirst
Do Until Rs.EOF
  'get the content class of each item
  ContentClass = Rs.Fields("DAV:contentclass").Value
  'test content class for calendar message
  If ContentClass = "urn:content-classes:calendarmessage" Then
    'open calendar message
    ItemURL = Rs.Fields(CdoDAV.cdoHref).Value
    iCalMsg.DataSource.Open ItemURL
    iCalMsg.Configuration = Config
    Debug.Print "Message subject: " & iCalMsg.Message.Subject
    'get each calendar part
    For Index = 1 To iCalMsg.CalendarParts.Count
      Set iCalPart = iCalMsg.CalendarParts(Index)
      Set iAppt = iCalPart.GetUpdatedItem
      Select Case iCalPart.CalendarMethod
        Case "CANCEL"
         'Save the appointment
         ' iAppt.DataSource.Save
         Wscript.Echo iAppt.DataSource.Save
        Case Else
          'see other examples in this section
      End Select
    Next
    'Delete the calendar message
    Wscript.Echo "Rs.Delete"
    ' Rs.Delete
  End If
Rs.MoveNext
Loop


Thank you,
Jeff
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Processing meeting cancellations using CDO/WebDAV

Post by jvierra »

The code you copied can only be run on an Exchange server. It is intended for use by integrated web servves like OWA and utilities that manage Exchange.
The NOTE frm the KB. What seems to be missing is a reference to the correct version of CDO. CDO with Exchange is different from teh client side CDO.
It is possible to do this from a client but it required the installation of Outlook and is easiest to do from Outlook VBA although it can be done from CDO.

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
This topic is 16 years and 9 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked