Galin Iliev's blog

Software Architecture & Development

Difficult Mapi.Sesstion initialization

I had hard couple days in resolving an issue related with initialization of MAPI session in child thread from .NET application. I tried bunch of situations but the result was same:
I got the error saying me that CDO cannot me initialized.

System.Runtime.InteropServices.COMException was caught
  Message="Retrieving the COM class factory for component with CLSID {3FA7DEB3-6438-101B-ACC1-00AA00423326} failed due to the following error: 80010106."
       at TSCGContactSearch.OutlookSearch.fGetOutlookSession(Object& olretNameSpace, Object& olretApp, Session& cdoretMapiSession) in D:\Projects\SCS\dotNet\ContactSearch\TSCGContactSearch\OutlookSearch.vb:line 614

I read in forums but still .. nothing...
I found this article form Stephen Griffin

I tried to call MAPIInitialization from child thred .. but still I get this anoying error.

Finally I came accross an article on MSDN in italian that gave me the idea to change ThreadingModel key in registry (under MAPI.Session's GUID) from "Both" to "Appartment" and ... here we go. No more errors. My application runs.


this was strange error as application was fine when was compiled under .NET 1.1 but .NET 2.0 breaks it. Very strange...


Comments (1) -

  • Gnana

    4/13/2007 4:19:10 AM | Reply


    i too have a sample problem with creating session in .net web application

    even i changed the registry setting as u said..

    CDO.SessionClass mySession =new CDO.SessionClass();

    the above line is giving error.

    is there any other solution for this.

    Thanks and Regards
    Gnana Prakash.