PRB: "Error 8002009 - MAPI_E_NOT_INITIALIZED 80040605" with CDO (1.x) (193451)



The information in this article applies to:

  • Collaboration Data Objects (CDO) 1.1
  • Collaboration Data Objects (CDO) 1.2
  • Collaboration Data Objects (CDO) 1.21

This article was previously published under Q193451

SYMPTOMS

Running a Collaboration Data Objects (1.1, 1.2, 1.21) application can produce the following error:
Error 8002009 - MAPI_E_NOT_INITALIZED 80040605

CAUSE

This error can be caused by having a CDO (1.1, 1.2, 1.21) action 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 (1.1, 1.2, 1.21) actions 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.

Modification Type:MinorLast Reviewed:3/4/2004
Keywords:kbFAQ kbMsg kbprb KB193451