PRB: "Error 8002009 - MAPI_E_NOT_INITIALIZED 80040605" w/ CDO

ID: Q193451

The information in this article applies to:

SYMPTOMS

Running a Collaboration Data Objects (CDO) application can produce the following error:

   Error 8002009 - MAPI_E_NOT_INITALIZED 80040605

CAUSE

This error can be caused by having a CDO activity being performed on the session object before the Session.Logon method is executed.

Any of the following methods can cause this error to occur:

   - Session.InfoStores
   - Session.OutOfOffice
   - Session.OutOfOfficeText
   - Session.CurrentUser
   - Session.Name

RESOLUTION

The Logon method must be called before any other CDO activities can be performed with the Session object prior to a successful logon. The only method that can be used before a successful logon is the SetLocaleIDs method of the Session object. In addition, you can access the Version property before a successful logon.

MORE INFORMATION

Steps to Reproduce Behavior

1. Create a new .asp page or create a Microsoft Visual Basic project.

2. If you are creating an .asp page, copy and paste the following code into

   the .asp file:

   NOTE: If you are creating a Microsoft Visual Basic project, paste only
   the statements between <% and %> into the project, and remove the
   "Server" from the first "Set objSession = " line.

    <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                             = <Valid ServerName>
      CONST strMailbox                            = <Valid MailboxName>

      Dim objSession
      Dim strProfileInfo

      strProfileInfo = strServer & vbLf & strMailbox
      Set objSession = Server.CreateObject("MAPI.Session")
      Response.Write(objSession.CurrentUser)

      objSession.Logon "", "", False, True, 0, True, strProfileInfo
      Response.Write("Logged into Mailbox as: " & objSession.CurrentUser _
           & "<br>")
      objSession.Logoff
      Set objSession = Nothing

    %>

    </BODY>
    </HTML>

3. When the script runs, you receive the error message listed in the
   SYMPTOMS section.

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

Last Reviewed: December 12, 1998