PRB: Access Denied Using CDO from VBScript

ID: Q179104

The information in this article applies to:

SYMPTOMS

You may receive the error "Access Denied" trying to invoke certain properties of Collaboration Data Objects (CDO) objects from VBScript (VBS) when the same operation succeeds from a Visual Basic application.

STATUS

This behavior is by design to ensure the security of message stores and address books.

MORE INFORMATION

Steps to Reproduce Behavior

   'Following is the VBScript code to reproduce the behavior:
   'This sample assumes that the CDO library is installed on the test
   'computer and that a profile named "Microsoft Outlook" exists.

   Sub but_OnClick
     Dim objSession
     Set objSession = CreateObject("mapi.session")
     objSession.Logon "Microsoft Outlook"
     MsgBox objSession.Inbox.Messages.Count 'This fails w/Access Denied
     objSession.Logoff
   End Sub

NOTE: This issue does not occur with all properties and methods; some operations (like sending messages) and some properties operate as expected.

REFERENCES

For information on where to acquire the most recent version of the CDO library tested for client-side use, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q171440
   TITLE     : INFO: Where to Acquire the Collaboration Data Objects
                Libraries

For additional information about Collaboration Data Objects versus Active Messaging, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q176916
   TITLE     : INFO: Active Messaging and Collaboration Data Objects (CDO)

Additional query words:
Keywords          : kberrmsg kbActMsg kbCDO110 kbCDO120 kbCDO121 kbMsg kbOLEMsg kbVBScript kbGrpMsg 
Version           : WINDOWS:1.1,1.2,1.21
Platform          : WINDOWS
Issue type        : kbprb

Last Reviewed: April 8, 1999