Error creating an MAPI session

  • Thread starter Thread starter Dominique Schroeder
  • Start date Start date
D

Dominique Schroeder

Here is the code below; I have problems with some machines and not others,
see comments in the code

thanks,

Dominique

sub item_open()

dim oSession 'MAPI session

dim strRetCode 'code to capture CDO success login



'clear error buffer

err.clear

on error resume next


'Use createobject to logon the CDO

' Need to use CDO to access access rights to MAPI folders

set oSession = application.createobject("MAPI.Session")

----- this is where it fails on some machines. Those are Office 2000 or
Office 2003 some have SP3 installed, one has SR1 (XP and windows 2000)

----- The error I get is -2147221005 Internal Application error

if not err.number = 0 then

msgbox err.number & " " & err.description

end if

'clear error buffer

err.clear

on error resume next

'Logon using an existing MAPI session

strRetCode=oSession.Logon("", "", false, false,0)

'error detected?

if not err.number = 0 then

msgbox "Could not establish CDO session"

oSession.logoff

Item_open = false

set oSession = nothing

strRetCode=0

exit sub

end if


etc...

end sub
 
Have you checked to see if those machines (a) have CDO 1.21 installed and (b) are running an anti-virus program that includes a script blocker to prevent OUtlook or CDO automation?

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
Back
Top